- Adding Virtual Host
- Enabling the availble site http://example
- Adding host name to the hosts file
- Changing the process owner of Apache2
If you have not already installed LAMP software, you can read my First steps after installing Ubuntu post, for installing the necessary Server software.
if apache starts, you can see the below error in terminal.
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
To rectify run the below code from terminal
sudo echo "ServerName localhost" | sudo tee -a /etc/apache2/apache2.conf
By default, Ubuntu place its web root at /var/www. Since, we want to have have multiple hosts for development, add virtual host. We also want, to mimic the cpanel configuration we have at the production server.
copy the default file to your new host name. It is not mandatory to have the host name, but it is easy to remember if you follow this convention.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example
Now edit the example file so that it reads as below.
Options Indexes FollowSymLinks MultiViews
allow from all
We want to have the production server name minus the .com or .net in the local development server, we can now enable our site using the command
sudo a2ensite example
Since your Server does not know how to resolve the name http://example, configures the hosts file accordingly.
gksu gedit /etc/hosts
add the host name example next your existing machine name.
127.0.0.1 yourmachine example
It will be very difficult for us to change the username between apache default username ‘www-data’ and ‘your username’, every time you add a new webfolder/host, so change the apache process name to your username and group.
gksu gedit /etc/apache2/envars
change the two lines in file envars, so that it looks like below.