-Site Map cristhian_alca@yahoo.com
cristhian_alca@yahoo.com
Apache and php Installation using Windows xp
APACHE SERVER SETUP

Download the windows binary from apache.org and execute the installer. Try installing apache as a service so it starts the next time you restart your computer.

I installed apache it in c:\apache2\apache, that is my $APACHE_HOME. The place were you can begin putting your html files is $APACHE_HOME\htdocs, but you can also modify the file httpd.conf in $APACHE_HOME/conf and specify aliases which point to other folders in your disk.

To modify apache's server settings go to the $APACHE_HOME\conf folder and edit httpd.conf. There we can create different aliases. Each alias point to a folder in your hard disk where you will store the files of a website. I usually create one alias for each website project i am working on, like this:

Alias /genericSite "d:/cristhian_files/websites/mysite1"

<Directory "d:/cristhian_files/websites/mysite1">
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

Once you are done with the alias setup you will be able to access that folder locally from:

http://localhost/genericSite

You can also change the port into wich apache will be listening for request, the default is the 80 port. Again, all the settings of the server go into the file httpd.conf.

Listen 80

You can change it to different ports (ex: 8080) if you have IIS or other server running on your computer.

To test if apache is running, and assuming you installed apache in port 80 open a browser and type:

http://localhost

You should be able to see the apache welcome page !

PHP 4 Setup

Go to php.net and get the zip file. At this point apache must be installed and running properly

I unzipped the file to c:\php4. Then searched for the php.ini file and copied it to c:\windows. There, you have to make some changes in the php.ini file (main php configuration file) located at c:/windows. If you see a line preceded by a # it means it's only a comment, so it's not part of the configuration.

1. If you want to mantain backwards compatibility with php scripts prior to version 4 you need to set this:

     register_globals = On .

2. Then modify the "extension dir" property in php.ini to the folder were you extracted php:

     ; Directory in which the loadable extensions (modules) reside.
     extension_dir = "d:/php4/"

3. I activated the gd library, that is necessary to resize jpeg images. Go and uncomment this in php.ini:

     extension=php_gd2.dll

4. I uncommented this line too, to be able to send emails using a default mail server i have.

     SMTP = localhost

5. Because i am using Sessions i need to specify a temporary folders to store them:

     session.save_path = c:\temp


Many other properties can be changed from php.ini

PHP 4 Integration with Apache

Now, to integrate PHP with apache you have to open again the apache conf file (httpd.conf). Go there and do the following:

1. First load the php module ( be careful with the quotation marks, i needed them though)
 
     LoadModule php4_module "c:/php4/sapi/php4apache2.dll"

2. then add this:

    AddType application/x-httpd-php .php

3. Finally add or modify the line with the property "DirectoryIndex" as follows:

    DirectoryIndex index.php index.html index.html.var


To test php just restart the computer. Then in $APACHE_HOME\htdocs create a file called hello.php with the following contents:

<?

echo "hello world";

?>

Then go to http://localhost/hello.php and if you see "hello world" it means php is running !