For the record, this applies to the following versions:
- Windows XP Professional
- Apache 1.3.31
- PHP 4.3.10
- MySQL 4.1.7
Let's get started!
Setting up Hosts
If you plan to use Apache's virtual hosts feature AND your testing server is on a different computer than the one you use, then you'll need to do some sorting out first. Virtual hosts allow you to run more than one website on a single web server. What this means is that you can have individual sites set up for each client, and be able to reference files in that site from the site root (or /) instead of just creating subdirectories for a single site as I have seen done elsewhere. For example, you can call
http://client1
and pull up their test site, and http://project3
and see a completely different site, that can possibly be saved in a completely separate location on your hard drive.For this to work, the computer running as your webserver should have a fixed IP address. And therefore each one of the computers in your intranet should also have fixed IPs. In Windows XP, click Start -> right-click My Network Places -> left-click Properties. (If you can't see it in your Start menu you can also get there via the Control Panel.) Then right-click the network connection that corresponds with your network card and left-click Properties. Scroll down the list if necessary until you can see TCP/IP. Double-click that and you'll see something like this:
In this example, my workstation is called 192.168.0.5 and the computer that actually connects to the internet is 192.168.0.1. (Actually that's the address of my modem/router, but that's another story!) Assign a number along these lines to each machine in your intranet and adjust these settings accordingly. You will probably also need to obtain the DNS server addresses from your ISP and enter them into the lower section.
On a standard Windows installation you will find a file called hosts (with no extension - ie it's not called hosts.txt or anything like that) in C:\Windows\system32\drivers\etc. Open it in Notepad (or any other text editor) and below it add the hostnames you want to use next to the IP address you've allocated for your testing server. If the IP address of your testing server is 192.168.0.200, you might add:
192.168.0.200 client1 project3
You can keep adding hostnames, separating them with a space. When you fill the line, start a new one with the same IP address, a tab, and keep going with more names. I'm not sure how many names you can legally put on a line, but I found it stopped working for me if I had too many, so if that happens to you reduce the number on each line.
You will need to copy this file into the directory mentioned above on each computer in your intranet.
Now we can move on to setting up Apache!
Apache
- Download the instalation file from www.apache.org and run it.
- When prompted, use your computer's name (intranet in my example) as the server name
- Choose the desination directory. I prefer to keep all these things together, so I used C:\webserver\apache
- After the installation has finished, fire up your browser and enter your computer's name or ip address. You should see something like this:
- Now comes the fun - editing the httpd.conf file!
- Line 342 - change
AllowOverride
toAll
(for htaccess files to work) - Line 385 - add extra filenames for the default document:
DirectoryIndex index.html index.php index.php4
- If you're using Virtual Hosts, uncomment Line 972 -
NameVirtualHost *:80
- Add details for your own virtual hosts as below:
- Don't forget to restart Apache after making changes to httpd.conf, which you can do via Start -> Apache -> Control -> Restart
PHP
- Download the zip version of PHP from www.php.net and extract to C:\webserver, then change full php directory from
php-4.3.10-Win32
to justphp
. - There's a note in the install instructions: "Note: In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g. C:\php)." - so do that. In this case, move them to c:\webserver\php
- To add the php directory to the system's path, right-click My Computer, choose the Advanced tab, and then click Environment Variables (near bottom of box). Find Path in system Variables, click Edit, and add ;c:\webserver\php to the end of what's already there. Don't forget the initial semi-colon. Click OK, then OK again. See below:
- Rename php.ini-recommended to php.ini (it's in the main php directory)
- Now to edit the php.ini file:
- Line 397 deals with Magic Quotes. Check what your remote host has them set to and make this the same.
- Line 443 - change to
extension_dir = "C:\webserver\php\extensions"
- Line 565 - uncomment the extension to load GD2
- Line 611 - add your ISP's SMTP server address
- Line 829 - Change to
session.save_path = "C:\webserver\php\temp"
and make sure you add a temp folder to your php folder
LoadModule php4_module "c:/webserver/php/php4apache.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# specify the directory where php.ini is
SetEnv PHPRC c:/webserver/php
# AddModule mod_php4.c
phpinfo()
in it and make sure it works!MySQL
- Download the 'essentials' version from www.mysql.com
- Choose custom install and change the installation directory as below:
- Choose Standard Config when prompted
- Install as a service
- Add root password (and don't forget what it is!)
- When done, create new file in the root of C called my.cnf, and add:
- If you haven't already, now is a good time to download phpMyAdmin and install that in a new folder with it's own hostname. Adjust the setting in its config file and fire it up. With a bit of luck you'll see two databases and you can start creating your own!
[mysqld]
basedir = C:webservermysql
datadir = C:webservermysqldata