To turn your box into a dev web server is pretty simple, yet I’ve seen people struggling with this over and over again, so here’s a simple TODO list.
I won’t go over the likes of Apache installation, VirtualHost setup, .htaccess settings, etc. as you can find these online very easily, and might be specific to the needs of your project.
Most of the time I see people using localhost:8080 and a myriad of other ports to work on several sites locally; but you might as well work on http://www.myproject.com locally in just 2 simple steps:
- Create a VirtualHost in Apache which goes by “the name” http://www.myproject.com, by including the following within the definition:
<VirtualHost *:80> ServerName www.myproject.com DocumentRoot /var/www/myproject/ # all the other options and definitions ... </VirtualHost>
- “Register” the domain name locally – simply add the following line to your /etc/hosts file (on Windows, this file is typically located under [Windows]/System32/Drivers/etc):
Now enable the VHost in Apache, restart Apache, and open http://www.myproject.com in the browser, and you’re ready to code off!
Note: The VHost name need not be a valid domain name – feel free to use myproject as ServerName and in /etc/hosts; just beware that some browsers will try to search for “myproject” instead of opening the local site. In such case, type in the whole http://myproject.