Home >Backend Development >PHP Problem >How to install php environment under windows
Installation method: 1. Install and configure Apache; 2. Download and unzip the php installation package to the specified path; 3. Copy a copy of "php.ini-development" and rename it to "php.ini" for installation. path, configure the file; 4. Load PHP in Apache and define the file for executing the PHP module.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
1. Apache
Because the Apache official website only provides source code, you must compile it yourself if you want to use it , here I choose the third-party installation package Apache Lounge.
Enter Apachelounge official download address: http://www.apachelounge.com/download/
First download and install vc redist, this It is a component necessary for Apache to run.
Download the decompressed version of Apache and place the decompressed folder in the path you want to install.
Modify the configuration file:
Apache’s default path is: c:\Apache24 (the version number may be different) . If it is different from your installation path, you need to open the Apach\conf\httpd.conf configuration file and change all c:\Apache24 and c:\Apache24 that are not commented with "#" in front of it. \htdocs and c:\Apache24\cgi-bin\ are changed to the corresponding paths.
Specify IP and port: Find ServerName www.example.com:80 in httpd.conf, remove the previous comment, and replace "www.example.com "changed to "localhost". If you want to modify the port, modify the "80" here together with the 80 in the previous "Listen: 80".
(Optional) Add system variables: Add "Apache installation path\bin" to Path.
Verify that the installation is successful: run Apache startup httpd.exe. Enter localhost:80 on the browser. If it is not inaccessible, then the Apache configuration is complete.
Tips: Register Apache as a Windows service
Install: apache’s bin directory Execute with administrator privileges
httpd.exe -k install
##Uninstall: Execute with administrator privileges under the bin directory of apache
httpd.exe -k uninstall
2. PHP
Note: The downloaded PHP VC version cannot be higher than the vc redist version installed previously.
Enter the PHP installation directory, copy a copy ofphp.ini-development and rename it php.ini Place it in the installation path, open it and find ;extension_dir= ext, remove the comments and change the value to PHP installation path\ext.
extension_dir = "D:/Program Files/php-7.2.10/ext"
LoadModule php7_module "PHP installation path\php7apache2_4.dll" # Load PHP as a module in Apache, the "7" in "php7_module" must be Corresponds to the PHP version; in addition, different PHP versions "php7apache2_4.dll" may be different.
PHPIniDir "PHP installation path" #Tell Apache the installation path of PHP
# 在Apache中以module的方式加载PHP,“php7_module”中的“7”要和PHP的版本对应;此外,不同的PHP版本“php7apache2_4.dll”可能不同。 #php 7.2.10 LoadModule php7_module 'D:/Program Files/php-7.2.10/php7apache2_4.dll' <IfModule php7_module> #告诉Apache PHP的安装路径 PHPIniDir 'D:/Program Files/php-7.2.10/php.ini' # define php module file .php和.html的文件能执行PHP程序 AddType application/x-httpd-php .php .html #AddType application/x-httpd-php-source .phps </IfModule>
PHP Video Tutorial"
The above is the detailed content of How to install php environment under windows. For more information, please follow other related articles on the PHP Chinese website!