Installing a Windows Dev Box

In the interest of saving this for future reference, here’s is a general how-to for installing a Windows based Web development server.

The reason for running up a Windows server as opposed to the typical LAMP alternative on Windows was due to frustration. The older Ubuntu server I had just made it very difficult to install the versions of PHP and MySQL that I wanted.

Applications I used were:
Apache 2.0.55
PHP 4.4.2
MySQL 4.1.18
Subverison 1.3

Download
The application packages you need to download are:
apache_2.0.55-win32-x86-no_ssl.msi
mysql-essential-4.1.18-win32.msi
php-4.4.2-Win32.zip
svn-1.3.0-setup.exe
svnservice (to run Subversion as a Windows service/daemon)

Installation
Now we’ve downloaded the right files we need to install them. for the most part this involves double-clicking the installer package and clicking Next a few times.

Install MySQL and use the Server Config tool to set options including Network Access.
Install Apache to the default location.
Unzip the PHP files to c:php folder.
Install Subversion using the package defaults.
Unzip the SVNService tool to the Subversion folder and copy the SVNService.exe file to the bin directory.

Configuration

PHP
In the c:php folder, copy the file php.ini-recommended to php.ini. Change the line that says,
doc_root =
to read
doc_root = c:progra~1apache~1apachehtdocs

Set the error reporting to a more appropriate level by changing the line that reads,
error_reporting = E_ALL
to
error_reporting = E_ERROR|E_PARSE

Copy php.ini to your Windows folder eg. c:windows

Add the directory path c:php to your system PATH variable, through My Computer→Properties→Advanced
Apache

Open the file c:progra~1apache~1apacheconfhttpd.conf and add the following lines,
LoadModule php4_module "c:/php/php4apache2.dll"
and further down,
AddType application/x-httpd-php .php

Edit: I neglected to add in some other lines when writing this. In the Apache conf file’s Module section add,
LoadModule dav_svn_module "C:/Program Files/Subversion/bin/mod_dav_svn.so"
LoadModule authz_svn_module "C:/Program Files/Subversion/bin/mod_authz_svn.so"
Of course you should change the path to match that of the library files in your Subversion install folder.

Create a file in c:progra~1apache~1apachehtdocs called test.php. In that file place this text,

<?php
phpinfo();
?>

Restart the server

Open your browser and go the URL http://your_server/test.php.

You should see a page listing the current PHP settings. If not, check that the Apache service is running and that you can browse to http://. If that works then check the PHP configuration.

Subversion
Create a folder to hold your Subversion repository eg. c:svn. In that folder create your folder structure for your code. Check the Subversion docs for the guidelines on how to do this the best way. To simply create a new repository called ‘project’ type the following line at a command prompt.
svnadmin create c:svnproject

At a command prompt type,
svnservice -install -d -r c:svnproject
which installs and starts the SVN service and tells it to run as a daemon (-d) and point to your code repository (-r xxxxx).

Open up Apache’s config file again (httpd.conf) and add the following code at the bottom of the file,
<Location /subversion>
DAV svn
SVNPath c:/svn/project
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile conf/svnusers.conf
Require valid-user
</Location>

This tells Apache that any requests for http://your_server/subversion, will use web_dav to look at your code repository at c:svnproject and only let authorized users see it.

Now we still need to tell Apache who is allowed to view our Subversion repository and who can read and write to our repo(sitory) too. At the cmd prompt again change directory to your Apache conf folder and type,
htpasswd -c svnusers.conf username
making sure you replace the ‘username’ with your real username. You’ll be asked to provide a password for that user which Apache will use.

And in the ‘project’ repo at c:svnproject open the conf folder and edit the svnserve.conf file with a text editor. Uncomment a few lines until you have at least,
[general]
anon-access = read ## Can be none, read, write
auth-access = write ## Can be none, read, write
password-db = passwd ## Filename of users store
realm = My Project

Now we need to create a passwd file to store the usernames and password used to control access to the repository. It’s a s imple as a text file with the lines below in it. Add extra users on new line but watch that both username and password are case sensitive.
[users]
myuser= mypassword

Extras
If you are unable to connect to the MySQL server using PHPMyAdmin or similar and receive a message like,
Error 1251: “Client does not support authentication protocol requested by server; consider upgrading MySQL client”, do not despair.

From a MySQL prompt on your server run the command below for each affected user@machine combination.

SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');

Making sure you replace the ‘user’ and ‘password’ with your own details.

Conclusion
Hope that all made sense, if not just leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *