Install and set up a web server on Debian or Ubuntu Linux

A web server allows to host dynamic content (pages, scripts, images, videos, files…) and make them available on the internet in a fast, reliable, secure and free way.

This post describes how to install and set up a web server on Debian or Ubuntu Linux that can host dynamic content and send emails.

Prerequisites

Change the hostname

I recommend using a single subdomain as hostname, eg dev.mydomain.com or prod-1.mydomain.com.

nano /etc/hostname

myhostname.mydomain.com

Define hosts

Only modify the lines corresponding to the local IP, IPv4 and IPv6 at the beginning of the file /etc/hosts. IPv4 and IPv6 to enter are those that point to the server (see Create and configure DNS records for a domain).

nano /etc/hosts

127.0.0.1 localhost # Local IP
xxx.xxx.xxx.xxx myhostname.mydomain.com myhostname # IPv4
xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx myhostname.mydomain.com myhostname # IPv6

Install Apache

Apache is the web server entry point. It serves as a bridge between internet users and the server’s resources (pages, scripts, images, videos, files…).

apt-get install apache2
a2enmod ssl
a2enmod rewrite

Install MySQL

MySQL is a database engine. It stores, organizes and returns the information required to generate dynamic content through the use of SQL queries (insert, select, update, delete…).

apt-get install mysql-server

Install PHP

PHP is a scripting language. It allows to generate dynamic content (pages, images, files…) from local or remote resources (files, databases, API…), then to transmit them to the user through Apache.

apt-get install php5

Install phpMyAdmin

phpMyAdmin is a web interface that manages the web server MySQL database.

apt-get install phpmyadmin

Web server to reconfigure automatically: apache2
Configure database for phpmyadmin with dbconfig-common? No

Install and set up Exim

Exim is a mail server (Mail Transfer Agent or MTA) that lets you send emails from Linux.

apt-get install exim4
dpkg-reconfigure exim4-config

General type of mail configuration: internet site; mail is sent and received directly using SMTP
System mail name: myhostname.mydomain.com
IP-addresses to listen on for incoming SMTP connections: 127.0.0.1 ; ::1
Other destinations for which mail is accepted:
Domains to relay mail for:
Machines to relay mail for:
Keep number of DNS-queries minimal (Dial-on-Demand)? No
Delivery method for local mail: mbox format in /var/mail/
Split configuration into small files? No

Additional recommended installations

  • Customizing the Apache user
    apt-get install apache2-mpm-itk
  • Optimizing PHP performance
    apt-get install php-apc
  • Automatic time synchronization
    apt-get install ntp
  • Files backup
    apt-get install rsync

» Create and set up an Apache virtual host
» Secure a web server on Debian or Ubuntu Linux
» Create and install a firewall on Debian or Ubuntu Linux
» Backup a server on Debian or Ubuntu Linux
» Useful commands for Debian or Ubuntu Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

*