Try to go to http://localhost/. If you don’t find anything there then turn on System Preferences > Sharing > Web Sharing.
On my 10.7 machine the default site location is at
/Library/WebServer/Documents/index.html.en You should be able to edit this file and see that http://localhost/ changes.
Now, we’d like to have an arbitrary folder contain our website, so I’ll use
~/Documents/IGL-website. Copy your websites source or put some source in this folder.
Now we setup the redirect necessary to send some local domain name (we’ll use
localigl to our website at
~/Documents/IGL-website. Open up the file
/private/etc/hosts and add the line:
Now you should see that going to http://localigl/ also directs to
Now edit the file
and add the following:
NameVirtualHost *:80 <Directory "/Users/YOURUSERNAME/Sites/"> Options Indexes MultiViews Includes AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localhost DocumentRoot /Users/YOURUSERNAME/Sites/ </VirtualHost> <Directory "/Users/YOURUSERNAME/Documents/IGL-website/"> Options Indexes MultiViews Includes AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName localigl DocumentRoot /Users/YOURUSERNAME/Documents/IGL-website/ </VirtualHost>
You’ll need to add executable permissions to the path preceding your website, so for my example this means:
chmod +x ~/Documents
To get php scripts working correctly, in
/private/etc/apache2/httpd.conf uncomment the following line to look like this:
LoadModule php5_module libexec/apache2/libphp5.so
Now, you must restart your apache server. The easiest way is to toggle System Preferences > Sharing > Web Sharing.
With all this, you should now be able to go to http://localigl/ and see your (possibly php-based) webpage.