Setting up your local environment after a reinstall is always a hassle. Especially if you like I don’t bother to back-up the configuration files. So what do you do to set up several sites on your local machine to work on, in Ubuntu using Apache 2.
1. Edit hosts file in /etc directory
Add this line to the hosts file for every site
127.0.0.1 localhost.yoursitename
2. Edit ports.conf file in /etc/apache2 directory
Make sure this is written in the file nothing else about listens etc
Listen 80 NameVirtualHost *:80
3. Edit your default file in /etc/apache2/sites-available directory
Put this on top before the VirtualHost bracket begins.
ServerName localhost4. Edit your myconfig file in /etc/apache2/sites-available directory
Add this for every site you add
ServerName localhost.yoursitename DocumentRoot /home/username/www/yoursitename/ Options Indexes FollowSymLinks MultiViews +Includes AllowOverride All Order allow,deny Allow from all
5. Restart Apache with: sudo /etc/init.d/apache2 restart