Home > Article > Backend Development > PHP and Apache installation and configuration examples sharing
This article mainly shares with you PHP and Apache installation and configuration examples, hoping to help everyone.
1. Install Apache
##1. Log in to http://httpd.apache .org/download.cgi
2. As shown in the picture, select a certain version of "Files for Microsoft Windows" option to enter the download page;
##3. As shown in the picture Display, select the first item "ApacheHaus"; in the new interface, you will find VC11 and VC14. Note here that you must remember that the selection of VC11 and VC14 must be consistent with the subsequent selection of PHP.
##4. After downloading, unzip the file to A folder, such as C:\Apache
5. Use Notepad to open the C:\Apache\conf\httpd.conf file and find: Define SRVROOT , set Define SRVROOT "C:\Apache", the value set here is the location of the previously decompressed folder.
If you need to modify the port, continue to find Listen 80 and change 80 to the port you want to set.
##6. Start the Apache HTTP Server. Use the Windows command line
bin folder under the folder, enter httpd -k install to complete the installation of the Apache service. 7. Double-click C:\Apache\bin\ApacheMonitor.exe to open the Apache console. After clicking start, enter http://localhost. The following page appears, indicating that the installation is successful.
2. Install PHP
1. Log in to http://www.php .net/, select the version you want to install. What needs to be noted here is that VC11 and VC14 must be consistent with the previous Apache selection when selecting the version. x86, x64 must be consistent with the actual situation of the machine.
2. Unzip the downloaded file to a folder, such as C:\php, and copy php.ini-production in the root directory copy and rename it to php.ini;
3. Set the environment variables and add C:\php and C:\php\ext to the environment variable PATH. That is, add;C:\php;C:\php\ext
## at the end of the Path variable to integrate Apache and PHP
1. Open C:\Apache\conf
with Notepad
Find ServerRoot and modify ServerRoot "C:\Apache" (the input here is the location where you decompressed the apache installation package)
Find #ServerName www.example.com:80 and change it to ServerName www.example.com:80 (remove the # in front)
## Find DocumentRoot "C:/Apache/htdocs", change to DocumentRoot "C:/Apache/htdocs" (if the same, no need to change)
## Search
Find DirectoryIndex index.html and change it to DirectoryIndex index.html index.php index.htm (here we added index.php index.htm)
Find ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/" and change it to ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin" (if it is the same, there is no need to change it)
## Find
Add LoadModule php5_module " in the last line of C:\Apache\conf\httpd.conf" C:/php/php5apache2_4.dll" let apache supports php (please confirm that C:/php/ has php5apache2_4.dll, if you download the connection I provided, it must be there)
Add AddType application/x-httpd-php .php .html .htm## Add PHPIniDir "F:/phptools/php5.5" (tell apache php .ini location)
At this point, the configuration of httpd.conf is completed, save httpd.conf.
2. Open F:\php\php.ini
Modify; extension_dir = "ext" to extension_dir = "ext" (remove the semicolon in front of extension)
Modify; extension=php_mbstring.dll to extension =php_mbstring.dll (remove the semicolon in front of extension, this is PHP multi-byte string extension)
Change;extension=php_mysql.dll to extension =php_mysql.dll (remove the semicolon in front of extension)
Change;extension=php_mysqli.dll to extension=php_mysqli.dll (remove the semicolon in front of extension) 三, Test Create phpinfo.php under C:\Apache\htdocs and write , Open the apache service and enter http://localhost/phpinfo.php in the browser. If the following page appears, the integration is successful!
#”cannot load php5apache2_4. dll into server" problem ## This problem occurs because of the V11 and V14 versions of Apache and PHP There is a mismatch, or the x86 and x64 versions of PHP are selected incorrectly. So be sure to select the matching version when downloading. Also pay attention to the version number of php php5apache2_4.dll Related recommendations:
The above is the detailed content of PHP and Apache installation and configuration examples sharing. For more information, please follow other related articles on the PHP Chinese website!