Sunday, November 1, 2009

Installing PHP with Apache as HTTP Server

First, install your selected HTTP (web) server (Like apache) on your system, and
make sure that it works.

Apache httpd.conf file editing for php

For PHP 4:
# Add to the end of the LoadModule section
LoadModule php4_module "c:/php/php4apache.dll"

# Add to the end of the AddModule section
AddModule mod_php4.c

For PHP 5:
# Add to the end of the LoadModule section
LoadModule php5_module "c:/php/php5apache.dll"

# Add to the end of the AddModule section
AddModule mod_php5.c

For both:
# Add this line inside the conditional brace
AddType application/x-httpd-php .php

# For syntax highlighted .phps files, also add
AddType application/x-httpd-php-source .phps


php installation
The following steps should be performed on all installations before the server specific instructions.
• Extract the distribution file to a directory of your choice. "C:\PHP\" is a good start.
The next step is to set up a valid configuration file for PHP, php.ini. There are two ini files distributed in the zip file,
[ php.ini-dist and php.ini-recommended. We advise you to use php.ini-recommended, because we optimized the default settings in this file for performance, and security. Read this well documented file carefully because it has changes from php.ini-dist that will drastically affect your setup. Some examples are display_errors being off and magic_quotes_gpc being off. In addition to reading these, study the ini settings and set every element manually yourself. If you would like to achieve the best security, then this is the way for you, although PHP works fine with these default ini files. Copy your chosen ini-file to a directory that PHP is able to find and rename it to php.ini. PHP searches for php.ini in the following locations (inorder):

* PHPIniDir directive (Apache 2 module only)
* HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath
* The PHPRC environment variable
* Directory of PHP (for CLI), or the web server's directory (for SAPI modules)
* Windows directory (C:\windows or C:\winnt)


If you are running Apache 2, the simpler option is to use the PHPIniDir directive (read the installation on Apache 2 page),otherwise your best option is to set the PHPRC environment variable.This process is explained in the following FAQ entry.
Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make sure that the user running the web server has read permissions to your php.ini (e.g. make it readable by Everyone).
• Copy the file, 'php.ini-dist' to your '%WINDOWS%' directory and rename it to 'php.ini'. Your '%WINDOWS%' directory is typically:
c:\windows for Windows 95/98
c:\winnt or c:\winnt40 for NT servers

Note: In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g. C:\php).

php.ini configuration


• You will need to change the 'extension_dir' setting to point to your php-install-dir, or where you have placed your 'php_*.dll' files. ex: c:\php

• If you are using Omni Httpd, do not follow the next step. Set the 'doc_root' to point to your webservers document_root. ex: c:\apache\htdocs or c:\webroot
doc_root = c:\apache\htdocs // for Apache (or wherever your apache installation root htdocs is placed)

• Choose which modules you would like to load when PHP starts. You can uncomment the: 'extension=php_*.dll' lines to load these modules. Some modules require you to have additional libraries installed on your system for the module to work correctly. The PHP FAQ has more information on where to get supporting libraries. You can also load a module dynamically in your script using: dll("php_*.dll");

• On PWS and IIS, you can set the browscap.ini to point to: 'c:\windows\system\inetsrv\browscap.ini' on Windows 95/98 and 'c:\winnt\system32\inetsrv\browscap.ini' on NT Server. Additional information on using the browscap functionality in PHP can be found at this mirror, select the "source" button to see it in action.

No comments:

Post a Comment