Installing PHP Files on Windows

Unlike building and installing PHP on Linux/Unix, installing PHP on Windows requires nothing more than downloading the distribution and moving a few files around. To download the PHP distribution files, go to the home of PHP, http://www.php.net/, and follow the link to the Downloads section. Grab the latest version of the zip package from the Windows Binaries section for this example we are using 4.2.3. Your distribution will be named something similar to php-version.zip, where version is the most recent release number.

Once the file is downloaded to your system, double-click on it to launch your unzipper. The distribution is packed up with pathnames already in place, so if you extract the files to the root of your drive, it will create a directory called php-version-Win32, and place all the files and subdirectories under that new directory.

Now that you have all the basic PHP distribution files, you just need to move a few of them around:

  1. In the PHP installation directory, find the php.ini-dist file and rename it php.ini.

  2. Move the php.ini file to C:\WINDOWS\ or wherever you usually put your *.ini files.

  3. Move the php4ts.dll file to C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files.

To get a basic version of PHP working with Apache, you'll need to make a few minor modifications to the Apache configuration file.

Integrating PHP with Apache on Windows

To ensure that PHP and Apache get along with one another, you need to add a few items to the httpd.conf configuration file. First, find a section that looks like this:

 # Example: # LoadModule foo_module modules/mod_foo.so # LoadModule access_module modules/mod_access.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_module modules/mod_auth.so #LoadModule auth_anon_module modules/mod_auth_anon.so #LoadModule auth_dbm_module modules/mod_auth_dbm.so #LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule autoindex_module modules/mod_autoindex.so #LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so #LoadModule expires_module modules/mod_expires.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule headers_module modules/mod_headers.so 

At the end of this section, add the following:

 LoadModule php4_module c:/php-version/sapi/php4apache2.dll 

Next, look for this section:

 # # AddType allows you to add to or override the MIME configuration # file mime.types for specific file types. # 

Add the following lines:

 AddType application/x-httpd-php .php .phtml .html AddType application/x-httpd-php-source .phps 

This ensures that the PHP engine will parse files that end with the .php, .phtml, and .html extensions. Your selection of filenames may differ, and you may wish to add .php3 as an extension, for backwards compatibility with any very old scripts you may have.

Any files with the .phps extension will be output as PHP source. That is, the source code will be converted to HTML and color-coded. This can be useful for debugging your scripts.

Save this file, and then restart Apache. If the server starts, PHP is now part of the Apache Web server.



Sams Teach Yourself PHP, MySQL and Apache in 24 Hours
Sams Teach Yourself PHP, MySQL and Apache in 24 Hours
ISBN: 067232489X
EAN: 2147483647
Year: 2005
Pages: 263

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net