This article mainly tells you how to integrate apache and PHP. For more information, see
This article mainly tells you how to integrate apache and PHP. For more information, see
After installing PHP, apache cannot process php files. To integrate php with the apache server, you must modify the configuration file. Here I will teach you how to configure the PHP installation file.
Method/step
First, add the following code to httpd. conf In the conf directory of apache:
LoadModulephp5_module ~ Php installation path/php5apache2_2.dll
PHPIniDir "~ Php module installation path"
AddTypeapplication/x-httpd-php.php.phtml
Here I will briefly explain the above Code. The whole code means to let apache load the php processing module (LoadModulephp5_module), in the code "~ The php installation path is changed based on the location of your php installation. For example, I installed it on drive D, so my path is: D: \ Myenv \ php-5.3.5 (note that the oblique rod here is the reverse oblique rod "\", in the Code to change to the positive oblique rod "/"), the position of the Code is added in httpd. add a lot of loadmodules In the conf file, as shown in:
Then you need to check whether the file "php5apache2_2.dll" exists in the directory you just added. In theory, you should check this file in case it is important, it serves as a bridge.
Next, we need to specify the PHP initialization directory, that is, the code "PHPIniDir '~ Php module installation path '". This code is used to specify the INI file of php. This file will configure php. In other words, you need to tell apache where your php is stored, similarly, we replaced the "~" in the Code with the installation path. Php module installation path"
Then I will explain to you the meaning of the last line of code, "AddTypeapplication/x-httpd-php.php.phtml" this sentence means to add the application type, in the vernacular, that is, when *. php starts to process the php file. You can add notes in the configuration file to facilitate your understanding, such:
Therefore, we need to change the path to two places. For example, mark the part in red and change the red part to the actual php installation path (note that it is a positive oblique pole)
In addition, php File Settings are also very important. Find php In Your php installation directory. ini-development file and change its suffix to php. ini, the reason for this change is: we need to set php in php. ini modification. For example, delete the deep blue part of the name.
After the change, the file looks like this, for example:
Now we need to specify the corresponding functional modules in php. ini. The specific method is to set the following code"
Extension_dir = "php extension library path" is added to the php. ini file you just modified. The purpose is to use various powerful php libraries. The "php extension library path" has a "ext" folder under the folder where you install php, open the php extension library in this folder. For example:
Now let's add the extension library path. Open the "php. ini" file in your notepad and find the "extension_dir" location. You can use the search to quickly locate the location. For example:
Replace "extension_dir = 'ext '" with the path of your php library. For example, my library path is: D: /Myenv/php-5.3.5/ext (also note that it is a diagonal bar), such as: Replace the blue part with your library path.
The final replacement result is as follows:
Now all our integration has been completed. You can test whether the integration is successful. Test method: call a simple php function. The function code is as follows:
<? Phpphpinfo ();?>
Restart apache to check whether it can be used.
If the integration is successful, you will be able to see the following shocking results.
How to integrate apache and PHP is clearer through the above ideas. If you are satisfied with the price comparison in this article, just like it.