It took me many hours of searching and trying different things to get virtual hosts working for my localhost, see below.
in your httpd.conf file you can add the following to the bottom under the sample virtual host, using your specifics of course in place of 'name':
Code:
<VirtualHost *:80>
ServerAdmin name@localhost.localdomain #(or just use root @ localhost if you prefer)
DocumentRoot /var/www/sitename
ServerName sitename.local #or whatever you're using
ServerAlias sitename
ErrorLog logs/sitename-error_log
CustomLog logs/sitename.local-access_log common
<Directory /var/www/sitename>
Options Indexes Includes FollowSymLinks
AllowOverride None
Allow from all
Order allow,deny
</Directory>
</VirtualHost>
That is also if you have it listening on port 80 -- I do not have port 80 open on my firewall, since I just use it on my localhost. You'll of course have to create the directories where ever you put the document root (under /var/www in my case). To test the syntax you can type 'httpd -S' in a terminal (without quotes).
Then you'll want to enter this in your /etc/hosts file for the virtual hosts you create:
Code:
127.0.0.1 sitename1.local sitename1
127.0.0.1 sitename2.local sitename2
Then, start or restart the httpd service and pull up the name page (i.e. sitename1.local) and you should see the Apache test page.