How to install the PHP development environment under Windows: 1. Download and install apache; 2. Modify the apache configuration file and add environment variables; 3. Install PHP and edit the configuration file; 4. Install mysql and add php_mysqli. dll extension.
1. Apache
(Recommended tutorial: php video tutorial)
Because Apache official website Only source code is provided. If you want to use it, you must compile it yourself. Here I choose the third-party installation package Apache Lounge.
Enter Apachelounge official.
First download and install vc redist, which 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:
The default path of Apache 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, c:\Apache24\htdocs and c:\Apache24\cgi that are not commented by "#" in front of it. -bin\ Change to the corresponding path.
Specify IP and port: Find ServerName www.example.com:80 in httpd.conf, remove the previous comment, and change "www.example.com" 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.
2. PHP
Installation and configuration PHP
Go to the official website under PHP to download the latest thread-safe version of PHP zip compressed package, decompress it and place it in the path you want to install.
Note: The downloaded PHP VC version cannot be higher than the vc redist version installed previously.
Enter the PHP installation directory, copy a copy of php.ini-development and rename it to php.ini and put it in the installation path. Open it and find ;extension_dir=ext. Remove the comment and change the value to PHP installation path\ext .
extension_dir = "D:/Program Files/php-7.2.10/ext"
Load PHP in Apache & define the file that executes the PHP module
Open the Apache configuration file conf \httpd.conf, find the LoadModule area, and add after it:
LoadModule php7_module "PHP installation path\php7apache2_4.dll" # Load PHP as a module in Apache, the "7" in "php7_module" It must correspond 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>
Test: Create a new file under Apache installation path\htdocs: test.php, edit it:, Start Apache, in Browser input: localhost:80/test.php.
3. MySQL
Download the corresponding installation version and install it according to your needs.
Load the assembly connecting to MySQL in PHP: add a line extension=php_mysqli.dll in the php.ini extension section.
Note: Different PHP versions may provide different assemblies for connecting to mysq. Go to the ext folder to see what PHP provides and write it here. Different assemblies may use different functions when connecting to the database.
Test: Edit: in test.php, start the database, restart Apache, and check on the browser. If there is no error message, the configuration is correct.
Related recommendations: php training
The above is the detailed content of How to install php development environment under windows. For more information, please follow other related articles on the PHP Chinese website!