First download the configuration files that need to be installed
1, apache-2.2.16
2, php-5.2.14-Win32
1. apache configuration
I won’t talk about the installation of apache. During the installation process, choose the location you want to install and click next. The default port is 80. After installation, enter http://localhost/ in the browser for verification. If successful, It works!
Apache configuration: The configuration file is located in %APACHE_HOME%confhttpd.conf in the installation directory. Modify the root directory DocumentRoot (two places in total). The port is also modified here.
2. PHP configuration
Unzip the downloaded php-5.2.14-Win32.zip. Be careful not to download the debug or none-thread-safe version of php when downloading. Otherwise, an error will occur after combining with apache.
Copy the decompressed php.ini-dist as a backup, then rename the original php.ini-dist to php.ini, open the file, and configure it.
1. Set the extension location: extension_dir = "%PHP_HOME%/ext" (To enable this setting after modification, remove the preceding semicolon, %PHP_HOME% is the decompression directory of php)
2. Open the extension you need: Remove the semicolon in front of extension=php_bz2.dll, extension=php_gd2.dll, extension=php_mysql.dll, extension=php_mysqli.dll (note the front There must be no spaces). If you want to open other extensions, remove the semicolons in front of the other extensions.
3. Time difference problem: search
;date.timezone =
modified to
date.timezone = PRC
4. Set up and integrate with apache
Open the apache configuration file httpd.conf in
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
Enter below this line:
LoadModule php5_module E:/php/php-5.2.14-Win32/php5apache2_2.dll
PHPIniDir "E:/php/php-5.2.14-Win32"
AddType application/x-httpd-php .php .phtml
Explanation:
The first line is the location of the dynamic link library needed to combine PHP with Apache. This file is in the root directory of PHP after decompression.
The second line is the path to the php.ini file
The third line tells the browser to forward the .php.phtml file to apache for parsing.
Restart Apache so that it can be associated with php. (Note that you must restart Apache every time you modify the Apache or PHP configuration file)
You should encounter the problem of garbled characters, and you will continue to add when you encounter it.
PS: Sure enough, I encountered garbled code. I used Eclipse for PHP Developers for development. In the preferences, the workspace encoding is set to utf-8 by default, but when the php or html page does not contain , then Chinese garbled characters will appear. Check that the encoding of the garbled file is already UTF-8. You must save it and resave it as UTF-8 before the garbled code disappears. It should be a BOM (Byte Order Mark) problem. The current solution: open the php.ini file, query the keyword: "default_charset", remove the preceding semicolon, change the value to utf-8, and restart apache.