Home  >  Article  >  Backend Development  >  PHP5+APACHE2.2 configuration_PHP tutorial

PHP5+APACHE2.2 configuration_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:09:44806browse


Due to the version update, these files have new names: I am using 5.4
php.ini-production corresponds to php.ini-recommended
php.ini-development corresponds to php.ini-dist
The other steps are still the same. The configuration file still needs to be modified, such as the path. Also, if you cannot find the libmysql.dll file, download one. Remember to make sure it is similar to the PHP version you are using. The PHP5.4 I use provides a download.

PS: My configuration just now was fine, but something went wrong when connecting to the database. It always prompted that the extension was not installed.... In fact, the PHP configuration file (the modified php.ini file is placed in the window, do not put it In the system32 file, for my test, I don’t need the libmysql.dll file. I just need to put php5ts.dll in the system32. There are (php_mysql.dll and php_mysqli.dll) in the e:php/ext file. It is enough to connect to it. There is no problem with the database)


PHP5+APACHE2.2 configuration success case:
First, install and configure APACHE (take mine as an example, install it to E:Program FilesApache Software FoundationApache2.2)
1. It is installed by default during installation. I fill in my computer name in Network Domain and Server Name, and fill in your email address in Administrator's Email Address
2. After installation, there is a conf folder in the installation directory. Open the httpd.conf file for configuration
·Find DocumentRoot and set it to the folder where you want to store php, htm and other web files, such as "E:Program FilesApache Software FoundationApache2.2htdocs";
·Find DirectoryIndex, add index.php, index.htm, etc. after index.html, separate them with a single space;
·Restart Apache and use http://localhost/ or http://127.0.0.1/ or http://yourcompanyname/ to test whether it is successful. If successful, there will be a message "It works!" on the screen
Second, install and configure PHP (unzip the PHP compressed package to d:php)
1. Rename the php.ini-recommended file to php.ini and cut it to the directory where the system is located (such as WINNT/system32 in 2000/NT, Windows/system32 in XP),
2. Change extension_dir to the directory where php/ext is located, such as "d:phpext";
3. Change doc_root to the same directory as in the first step, such as "E:Program FilesApache Software FoundationApache2.2htdocs";
4. Find ;session.save_path = "/tmp", remove the ';', and set the directory where you save the session, such as session.save_path = "D:/php/session_temp";
5. Then remove the semicolons in front of the following sentences to better support Mysql and PHPmyadmin
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_mysql.dll
Third, PHP+APACHE
1. Allow Apache to run PHP programs as modules:
Open httpd.conf and add the following content (any position):
LoadModule php5_module "d:/php/php5apache2_2.dll" (Pay special attention to this one, many places call php5apache2.dll, so when running PHP code, an httpd.exe application error will be prompted)
AddType application/x-httpd-php .php
       AddType application/x-httpd-php .htm
(.htm, .php are the extensions of the executable php language, you can also add html, php3, php4, or even txt)
(The following two steps are not required)
2. If you need to run a PHP program in CGI mode (using Php.exe) for some reason,
Please turn the above line into a comment (just add # at the beginning of each line) and add the following lines:
                                ScriptAlias ​​/php/ "d:/php/"
​​​ # AddType application/x-httpd-php .php
​​​ #Action application/x-httpd-php "/php/php-cgi.exe"
3. Now apache 2 supports HTML but not PHP. First add the following sentences to d:apache2confhttpd.conf:
​​​ # ScriptAlias ​​/php/ "d:/php/"
​​​ # AddType application/x-httpd-php .php
​​​ #Action application/x-httpd-php "/php/php-cgi.exe"

Fourth, restart the service
1. Find php5ts.dll and libmysql.dll in d:PHP and copy them to c:winntsystem32 (winNT/2000 machine), while winXP/2003 is copied to c:windowssystem32
2. Test whether the connection between Apache and php is successful:
Start apache service or restart apache if it is running
3. Create a new test.php in the Web root directory (that is, under the E:Program FilesApache Software FoundationApache2.2htdocs directory)

test

phpinfo();
?>

4. Run http://localhost/test.php
If successful, you should see a web page with the PHP logo and lots of settings and other information
So congratulations

Remarks:
If it cannot run, it cannot be started after installing PHP5.1.* + apache 2.2.2 using the traditional modular method,

Tips:
"Cannot load D:/php/php5apache2.dll into server: The specified module could not be found."

Reason:

The php5apache2.dll in the PHP compressed package is only suitable for apache2.0.*. Whether to change php5apache2.dll to php5apache2_2.dll is the first small step of the third step
Another solution:

vcredist_x86.exe
php5apache2.dll
httpd.exe.manifest
1. Overwrite the php5apache2.dll file in your original PHP directory with php5apache2.dll.
2. Copy the httpd.exe.manifest file to the bin folder in your apache installation directory.
3. Double-click to run vcredist_x86.exe to install.
Done! Go and try restarting your apache.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477613.htmlTechArticleDue to the version update, these files have new names: the 5.4 I use corresponds to php.ini-production php.ini-recommended php.ini-development corresponds to php.ini-dist. The other steps are still the same...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn