- Add your host name to your hosts file
- Open a terminal and type: sudo nano /etc/hosts
- Add "127.0.0.1 test" to the bottom of your hosts file, without the quotes.
- Enable apache vhosts file
- open your httpd.conf
- in a terminal type: cd /private/etc/apache2
- then: sudo nano httpd.conf
- find the line #Include /private/etc/apache2/extra/httpd-vhosts.conf
- remove the # at the beginning of the line (if it has one, if not, your good to go)
- Add the folder you want the host to reference to the httpd-vhost.conf file
- back in the terminal: cd extra
- then: sudo nano httpd-vhosts.conf
- add the following to the bottom of the file, changing the DocumentRoot, directory paths and log file names appropriately.
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/User/patrickc/www/test" ServerName test ErrorLog "/private/var/log/apache2/test-error.log" CustomLog "/private/var/log/apache2/test-access.log" common <directory "/User/patrickc/www/test/"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </directory> </VirtualHost>
- Restart apache
- in your terminal; sudo apachectl restart (on some setups it might be; sudo apache restart)
- Then open a browser and type http://test
- That should be it, if you get a permissions error check the value in <directory />
Saturday, 16 March 2013
Adding a virtual host on mac
Quickly adding a virtual host on mac (10.6) assuming your adding the host name "test".
Subscribe to:
Posts (Atom)