After a long history of PHP configuration development, many users are familiar with PHP. here I will share my personal understanding and discuss it with you. Next we will introduce the PHP configuration steps. Although PHP source code can be downloaded, like Apache2, it is best to directly use the binary distribution package. Experience Summary PHP application skills experience PHP form repeated submission problem solution in-depth introduction to PHP date format new PHPCookie settings for year, week, and day learning PHP configuration
PHP has been developing for a long time and many users are familiar with PHP. here I will share my personal understanding and discuss it with you. Next we will introduce the PHP configuration steps. Although PHP source code can be downloaded, it is best to directly use the binary distribution package like Apache 2.
- Experience Summary PHP application skills
- Experience: PHP form repeated submission solution
- In-depth introduction to PHP date format leap year, week, day
- New PHP Cookie setting method secrets
- Complete PHP configuration steps in five minutes
Apache 2 can run the PHP program in two ways: run the program through a cgiinterface (external call php.exe), or run the php dll file inside Apache. The latter method is faster. Therefore, for each version of PHP, two Windows binary release packages are provided. The smaller one is the. msipackage. the cgiexecutable program php.exe is installed, but the module required to run the PHP script through Apache DLL is removed. The larger. zip package contains all these items. you can download them from the Win32 region of the snaps.php.net website. After the file is downloaded, decompress it to C: \ Php (keep the folder name ). Unless you are absolutely certain, please download the PHP manual at the same time. it has multiple language versions available.
PHP configuration
Now we come to the most interesting part: the perfect combination of Apache and PHP. First, copy all DLL files in the C: \ Php \ Dlls directory to the Windows System directory (% windir % \ System ). Next, find the section containing a large number of AddType commands in the Apache configuration file (Httpd. conf) and add the following line by yourself:
- AddType?application/x-httpd-php?.php?
Copy C: \ Php. ini-recommended to the Windows directory (% windir %), rename it Php. ini, and open it in a text editor. Edit the three rows set for doc_root, extension_dir, and session. save_path to make them consistent with the one shown below. Note that you should replace InstallDir with the name of your Apache 2 installation directory.
- doc_root?=?c:\apache\apache2\htdocs ?
- extension_dir = c:\php\extensions ?
- ?
- session.save_path = c:/temp ?
?
The next step is to allow Apache to run the PHP program as a module, which requires two steps. First, copy C: \ Php \ Php4ts. dll to the Windows System folder (% windir % \ System ). Find the LoadModule section in Httpd. conf and add the following line by yourself:
- LoadModule?php4_module?“c:/php/php4apache2.dll”?
If you run the PHP program (use php.exe) in the cgimodel for a specific reason, change the above line to a comment and add the following lines in Httpd. conf:
- ScriptAlias?/php/?"c:/php/" ?
- ?
- Action?application/x-httpd-php?"/php/php.exe" ?
Is everything done?
After saving the changes, you need to prove two points in person to ensure that Apache 2/PHP 4 becomes a perfect partner: can Apache load normally? Can It process PHP pages correctly?
To check whether Apache can be loaded properly, enter the following command in the command line window that you have opened:
- apache–k?start?
In addition, if Apache is running, run the following command to restart it:
- apache–k?restart?
The benefit of starting Apache from a command line is that Apache immediately reports an error. The most common problem you may encounter is that Apache may be unable to load Php4apache2. dll for some reason. If Apache reports this error, repeat the preceding steps to ensure that everything is correct. To know if Apache can process the PHP page correctly, use your text editor to create a simple PHP page named Phptest. php, which contains only the following line:
- <??phpinfo();??>?
Save the file to the main Web server directory (C: \ InstallDirectory \ Apache \ Apache2 \ Htdocs) and access http: // localhost/phptest. php in a browser. If everything is normal, you should see a webpage containing the PHP logo, which contains a lot of settings and other information. To know whether PHP is currently running through CGI or inside Apache, check the environment variable orig_script_name. If PHP runs through CGI, the value of this variable is/Php/Php.exe. If Apache runs the PHP script as a module, the value of this variable should be/Phptest. php.
It is not easy to install Apache 2 and PHP on Windows, but there is no need to cross the river by feeling the stones. Through the instructions in this article, you should be able to quickly set up the best in history and the most cost-effective