Eat Chips

Drink Beer

> Home > Science > Local Web

Local World Wide Web

How to set up the World Wide Web on your own computer using Windows, Apache and PHP

This assumes you have already set up Apache and PHP on your windows machine. I am going to set up so that when entered in the address bar of the browser, the local version will be served up.

Step 1: HOSTS file.
Find the HOSTS file on your computer. It is usually located in the Windows directory on the C drive. Try C:\WINDOWS\system32\drivers\etc or something similar.
Edit the file in Notepad or any other text editor and add the line(s):

Step 2: Apache config file.
Find the httpd.conf file in the Apache installation directory in the conf directory. Try C:\Program Files\Apache Group\Apache2\conf
Edit the file and add the following at the end of the file:

<VirtualHost *>
DocumentRoot /home/htdocs
ServerName localhost
<VirtualHost *>
DocumentRoot /home/thegibbo/htdocs
# or DocumentRoot "C:/home/thegibbo/htdocs"

Note that the first VirtualHost must point to the default directory for the Apache installation. You can then enter as many VirtualHosts as required.

Step 3: PHP config file.
Find the php.ini file in the PHP installation directory. In order for PHP files to be processed from any directory the doc_root directive must be empty. Therefore find the line that begins with 'doc_root' and edit it so that it reads:

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
doc_root = 

Step 4: Bounce Apache
If you installed Apache as a service, it will need to be stopped and restarted for the changes to take effect.

Bonus: Sending form mails

And, as an added tip, if you want to test your PHP form action pages that send emails, again edit the PHP config file and look for the line that begins with 'SMTP' and add your SMTP server that you use with your mail client eg:

[mail function]
; For Win32 only.

Et voila! Your very own World Wide Web on your own computer.