PHP after a long period of development, a lot of users are very familiar with PHP, here I publish a personal understanding, and discuss with you. Let's take a look at the steps for PHP configuration. Although you can download PHP source code, but like Apache 2, it is best to use the binary distribution package directly.
Apache 2 can be used in 2 ways to run PHP programs: Run via a CGI interface (external call to Php.exe), or use PHP DLL files to run inside Apache. The latter way is faster. Therefore, for each version of PHP, 2 windows binaries are available. The smaller is the. msi package, which installs the CGI executable Php.exe, but it takes away the modules required to run PHP scripts through the Apache DLL. The larger. zip package contains all of these items and you can download them from the Win32 area of the Snaps.php.net website. Once the file has been downloaded, unzip it to c:php (keep the folder name). Unless you are absolutely sure, please also download the PHP manual, which is available in multiple languages.
PHP Configuration
Now comes the most interesting part: the perfect match between Apache and PHP. First, copy all the DLL files in the C:phpdlls directory to the Windows System directory (%windir%system). Next, look for the section in the Apache configuration file (httpd.conf) that contains a large number of ADDTYPE commands and add the following line yourself:
Copy the c:phpphp.ini-recommended to the Windows directory (%windir%), rename it to PHP.ini, and open it with a text editor. Edit the 3 lines in which the Doc_root, Extension_dir, and Session.save_path are set to match the one shown below, and note to replace the installdir with the name of your Apache 2 installation directory.
- Doc_root = C:apacheapache2htdocs
- Extension_dirc:p hpextensions
- Session.save_pathc:/temp
It is permissible to use both forward slash and backslash in Session.save_path. The PHP configuration claims that these path parameters need to be added at the end of a backslash, but this argument is incorrect. You do not need to do this in PHP 4.3. In addition, if C:temp does not exist, create it yourself.
The next step is to allow Apache to run the PHP program as a module, which requires you to take 2 steps. First, copy the C:phpphp4ts.dll to the Windows System folder (%windir%system). Find the LoadModule section in httpd.conf and add the following line yourself:
If you need to run a PHP program in CGI mode for some reason (using Php.exe), turn the line above into a comment and add the following lines in httpd.conf:
- scriptalias/php/"c:/php/"
- Action application/x-httpd-php "/php/php.exe"
Has everything been done?
After you save your changes, you need to prove two points in person to make sure Apache 2/php 40% is a perfect pair: can Apache load properly, and can it handle PHP pages correctly?
To see if Apache can load properly, enter the following command in the Command line window that you have opened:
Also, if Apache is running, you can restart it with the following command:
The advantage of starting Apache from the command line is that if an error occurs, Apache will report it immediately. The most common problem you might encounter is that Apache may not be able to load Php4apache2.dll for some reason. If Apache reports this error, follow the steps described earlier to make sure that nothing is wrong. To know if Apache can properly handle PHP pages, use your text editor to create a simple PHP page named phptest.php, which contains only the following line:
Save the file to the main Web server directory (C:installdirectoryapacheapache2htdocs) and use the browser to access the http://localhost/phptest.php. If everything works, you should see a Web page with a PHP logo that contains a lot of settings and other information. To know whether PHP is currently running through CGI or inside Apache, you can 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 the variable should be/phptest.php.
Although installing Apache 2 and PHP on Windows is not an easy task, there is absolutely no need to take a stones approach. With the instructions in this article, you should be able to quickly build the best, most cost-
http://www.bkjia.com/PHPjc/446500.html www.bkjia.com true http://www.bkjia.com/PHPjc/446500.html techarticle PHP After a long period of development, a lot of users are very familiar with PHP, here I publish a personal understanding, and discuss with you. Let's take a look at the steps for PHP configuration. Although can ...