Installing PHP
Prev | Chapter 4. Setting up moregroupware on Windows | Next

## Installing PHP

- Unzip the php zip - file to C:\php (To unzip the files you will need Powerarchiver or Winzip or a similar tool).

- Use Windows Explorer to get into the folder `C:\php`

- Rename php.ini-dist to php.ini and open the file in a text editor (e. g. Notepad).

- Create the folder `C:\web` where we shall store the HTML/PHP files.

- You must do two changes in the file: `doc_root` shall be changed to `doc_root = "c:\web"` and `extension_dir` shall be changed to `extension_dir = "c:\php\extensions"`

- Save the file.

Usually not necessary: If you get problems with the Apache/PHP-integration you can try to move (or copy) both `php.ini` and `php4ts.dll` to your windows path (e. g. `C:\winnt` or `C:\windows`).

Some times you also have to change the Windows include path in `php.ini` from `;include_path = ".;c:\php\includes"` to `include_path = "."` (remove ; and at least use a dot (.) as include_path.)

The default setting for register_globals is off. It is a security risk to set it to on, but at the moment you must do it to get all the functions in MGW to work: `register_globals = On`

You must also do some configuration changes in the Apache configuration file to get PHP to work. Open `C:\web\Apache\conf\httpd.conf` in your text editor (e. g. Notepad) and do the following changes:

    DocumentRoot "C:/web"

    <Directory "C:/web">

Use / (forward slash) and NOT \ (backslash)!!!!

Find the line `AddType application/x-tar .tgz` and add the following lines below:

            ScriptAlias /php4/ "c:/php/"
            AddType application/x-httpd-php .php
            AddType application/x-httpd-php .php3
            AddType application/x-httpd-php .php4
            Action application/x-httpd-php "/php4/php.exe"

To avoid file listing in stead of running `index.php` files you can add `index.php` to the `DirectoryIndex` parameter:

            DirectoryIndex index.html index.php

Save your file. You now have to restart the Apache web server to activate the changes.

After restarting the Apache server you can make a test file to check that the PHP extensions work. Start your text editor, write

    <?php phpinfo(); ?>

and save the file in `C:\web` as `test.php`

Start your webbrowser with the web page `http://localhost/test.php` or `http://yourPCname/test.php`. You should get a lot of information about PHP.

### Setting up PHP as Apache module

Above we have set PHP Server API to CGI. To get better speed etc. it can be a smart move to change from CGI to Apache. To do that you must open httpd.conf and replace the lines below:

    ScriptAlias /php4/ "c:/php/"
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    AddType application/x-httpd-php .php4
    Action application/x-httpd-php "/php4/php.exe"

with:

    LoadModule php4_module c:/php/sapi/php4apache.dll
    AddModule mod_php4.c
    AddType application/x-httpd-php .php

You must MOVE `php4ts.dll` from `C:\php` to `C:\windows\system32` (or `C:\winnt\system32`). `php.ini` should be moved to `C:\windows` (or `C:\winnt`). Stop and start Apache to activate the changes.

Prev | Up | Next
Installing Apache | Home | Installing MySQL