[ Team LiB ] Previous Section Next Section

Configuring Apache

After you have compiled PHP and Apache, you should check Apache's configuration file, httpd.conf, which you will find in a directory called conf in the Apache install directory. Add the following lines to this file:


AddType application/x-httpd-php .php

This ensures that the PHP engine will parse files that end with the .php extension.

If you want to offer to your users PHP pages with extensions more familiar to them, you can choose any extension you want. You can even ensure that files with the .html extension are treated as PHP files with the following:


AddType application/x-httpd-php .html

Note that treating files with the .html extension as PHP scripts could slow down your site because every page with this extension will be parsed by the PHP engine before it is served to the user.

If PHP has been preinstalled and you have no access to the Apache configuration files, you might be able to change the extensions that determine which files are treated as PHP executables by including an AddType directive in a file called .htaccess. After you have created this file, the directive affects the enclosing directory, as well as any subdirectories. This technique works only if the AllowOverride directive for the enclosing directory is set to either FileInfo or All.

Although the filename .htaccess is the default for an access control file, it might have been changed. Check the AccessFileName directive in httpd.conf to find out. Even if you don't have root access, you might be able to read the Apache configuration files.

An .htaccess file can be an excellent way of customizing your server space if you do not have access to the root account. The principal way of configuring the behavior of PHP, however, is the php.ini file.

    [ Team LiB ] Previous Section Next Section