Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of integrating apache and php

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Know how to integrate apache and php? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

We know that after installing PHP, apache can't actually process the php file, and if we want to integrate php with the apache server, we have to modify the configuration file.

The methods are as follows:

First, add the following code to httpd.conf under 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 load apache into the php processing module (LoadModulephp5_module). The "~ php installation path" in the code is changed according to the location where you installed the php. For example, I installed it on disk D, so my path is: d:\ Myenv\ php-5.3.5 (note that the slant here is a backslash "/", and change it to a positive diagonal in the code). The code can be added under a large number of LoadModule in httpd.conf, as shown in the following figure:

Then you need to check whether there is this file "php5apache2_2.dll" in the directory you just added, in theory, just in case, this file is very important and acts 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, which will configure php. To put it colloquially, you need to tell apache where your php is. In the same way, we replace the "~ php module installation path" in the code with the installation path.

Then I'll explain to you what the last line of code means. "AddTypeapplication/x-httpd-php.php.phtml" means to add an application type, and in vernacular, that is, when a *. Php file appears, php starts processing the file. You can add comments to the configuration file to facilitate your understanding, as shown below:

So, there are two places where we need to change the path. In the following picture, the red part is marked with red, and the red part is changed to your actual installation php path (note that it is a positive diagonal).

In addition, the php file settings are also very important. Find the php.ini-development file in your php installation directory and change its suffix name to php.ini. The reason for changing this is: our php settings need to be modified in php.ini. As shown below: delete the dark blue part of the name.

After the correction, the file looks like this, as shown in the following figure:

Now we need to specify the corresponding function module in php.ini by adding the following code

Extension_dir= "php extension library path" is added to the php.ini file you just modified. The purpose of this is to be able to use the various powerful libraries of php, and the "php extension Library path" has a "ext" folder under the folder where you installed php, which is full of php extension libraries. As shown below:

Now let's add the extension library path, open the "php.ini" file with your notepad and find the "extension_dir" location, which you can use to find it quickly. As shown below:

Then replace the location "extension_dir='ext'" with the path of your php library, take mine as an example, my library path is: D:/Myenv/php-5.3.5/ext (also note that it is a positive diagonal bar), as shown below: replace the blue part with your library path.

The final replacement result is as follows:

Now that our integration is complete, we can test whether it is successful or not. Test method: call a simple php function with the following code:

Then restart your apache to see if it works.

If you integrate successfully, you can see the following shocking effects.

Thank you for reading! After reading the above, do you have a general idea of how to integrate apache and php? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report