Your Web server needs to be configured to recognize PHP scripts and run them.
Configuring Apache on Linux and MacYou must configure Apache to recognize and run PHP files. An Apache configuration file, httpd.conf, is on your system, possibly in /etc or in /usr/local/apache/conf. You must edit this file before PHP can run properly.
Follow these steps to configure your system for PHP:
Find the list of LoadModule statements. Look for the following line:
LoadModule php5_module libexec/libphp5.soIf this line isn’t there, add it. If a pound sign (#) is at the beginning of the line, remove the pound sign.
For PHP 6, the line will be:
LoadModule php6_module libexec/libphp6.so
You need to tell Apache which files might contain PHP code. Look for a section describing AddType. You might see one or more AddType lines for other software. Look for the AddType line for PHP, as follows:
AddType application/x-httpd-php .php
If you find it with a pound sign (#) at the beginning of the line, remove the pound sign (#). If you don’t find this line, add it to the AddType statements. This line tells Apache to look for PHP code in all files with a .php extension. You can specify any extension or series of extensions.
You can start or restart the server with a script that was installed on your system during installation. This script might be apachectl or httpd.apache, and might be located in /bin or /usr/local/apache/bin. For example, you might be able to start the server by typing apachectl start, restart it by using apachectl restart, or stop it by using apachectl stop. Sometimes restarting is not sufficient; you must stop the server first and then start it.
You can’t have Apache and IIS running at the same time using the same port number. Either shut down one Web server or tell them to listen on different ports.
You must edit an Apache configuration file, called httpd.conf, before PHP can run properly. To configure Apache for PHP, follow these steps:
To edit the file, choose Start-->Programs-->Apache HTTPD Server-->Configure Apache Server-->Edit Configuration.
If Edit Configuration isn’t on your Start menu, find the httpd.conf file on your hard drive, usually in the directory where Apache is installed, in a conf subdirectory (for example, c:\program files\Apache group\Apache\conf). Open this file in an editor, such as Notepad or WordPad.
Look for the module statement section in the file and locate the following line:
#LoadModule php5_module "c:/php/php5apache2.dll"Remove the # from the beginning of the line to activate the module. If you install PHP 6, you need the following line:
LoadModule php6_module "c:/php/php6apache2.dll"
If you are using Apache 1.3, rather than Apache 2, the module name is php6apache.dll or php5apache.dll. If you are installing Apache 2.2, the module name is php6apache2_2.ddl or php5apache2_2.dll.
Look for a section describing AddType. This section might contain one or more AddType lines for other software. The AddType line for PHP is
AddType application/x-httpd-php .phpLook for this line. If you find it with a pound sign (#) at the beginning of the line, remove the pound sign. If you don’t find the line, add it to the list of AddType statements. You can specify any extension or series of extensions.
This line tells Apache that files with the .php extension are files of the type application/x-httpd-php. Apache then knows to send files with .php extensions to the PHP module.
You can start it as a service on Windows NT/2000/XP/Vista by choosing Start-->Programs-->Apache HTTPD Server-->Control Apache Server and then selecting Start or Restart. You can start it on Windows 98/Me by choosing Start-->Programs-->Apache Web Server-->Management.
Sometimes restarting Apache is not sufficient; you must stop it first and then start it. In addition, your computer is undoubtedly set up so that Apache will start whenever the computer starts. Therefore, you can shut down and then start your computer to restart Apache.
You should be able to enter by choosing Start-->Programs-->Administrative Tools-->Internet Services Manager or Start--> Control Panel-->Administrative Tools-->Internet Services Manager.
Repeat Steps 6-10 if you want any extensions in addition to .php to be processed by PHP, such as .phtml.