How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

慕斯
Release: 2023-04-10 06:34:01
forward
16495 people have browsed it

How should we set up a PHP development environment (Apache PHP MySQL) in a Windows environment? "Xiaobai" will take you to find out. Let's set off together! ! !

How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Install Apache

1. Download Apache, address: http://www.apachelounge.com/download/, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
2. Unzip the compressed package. It is best to put it in the root directory of the disk, otherwise it is easy to report a path error during configuration. I changed the folder name here to facilitate future configuration, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Install PHP

1. Download the PHP compressed package at: https://windows.php.net/download. I downloaded the PHP7.0 Thread Safe version, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
2. Unzip the compressed package. I unzipped it as follows:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Install MySQL

1. The MySQL55 version I installed, MySQL will not be introduced here. For the installation method, you can search online
2. MySQL official download address: https://dev.mysql.com/downloads/installer/
3. MySQL default installation directory is as follows:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configuring MySQL

1. Check in the environment variable page
The specific operations are as follows: My Computer-right-click-Properties-Advanced System Settings-Environment Variables
2. Create a new MYSQL_HOME variable, The value is the installation path of MySQL, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Edit the path system variable and add %MYSQL_HOME%\bin to the end of the path variable
4. Start MySQL and enter the command line: start mysqld, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configuring PHP

1. Open the PHP installation directory and copy php.ini-development first, and then copy php.ini- Development is changed to php.ini and saved
2. Open php.ini to modify the configuration and search for; extension_dir = “ext” and change it to extension_dir = “ext’s directory”, for example, extension_dir = “D:\Software\php7\ext” , as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Open several commonly used extensions, for example: find extension=php_mysqli.dll and remove the preceding semicolon. Open the libraries in the picture below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configuring Apache

1. Open the installation directory of Apache, find the httpd.conf file in the conf folder and open it
2. Find the "Define SRVROOT" item and change the value in the quotation marks to the installation directory of Apache, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Add support for PHP and The installation path of PHP is as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
The code is as follows:

# php7 supportLoadModule php7_module "D:/软件/php7/php7apache2_4.dll"AddType application/x-httpd-php .php .html .htm# configure the path to php.iniPHPIniDir "D:/软件/php7"
Copy after login
Copy after login

Start the Apache service

1. Set environment variables
Right-click My Computer, Properties->Advanced, find the environment variables button at the bottom, select the current user's PATH variable, edit and create the following Entry:
D:\Apache24\bin
D:\Software\php7
D:\Software\php7\ext
2. Install apache service
Open the command line as an administrator, Execute httpd.exe -k install
3. Start the service
Find the bin folder in the installation directory of apache, double-click ApacheMonitor.exe, and apache will be started after double-clicking.
You can select the icon below in the taskbar, right-click to open the Apache Service Monitor window, and manage the Apache service
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
4. At this time, enter localhost in the browser address bar and press Enter. The apache interface appears, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
5. Next, create a new phpinfo.php file in the Apache installation directory/htdocs directory, with the content:

Copy after login
Copy after login

After saving, Enter 127.0.0.1/phpinfo.php in the browser, press Enter, and the version information about PHP will appear, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

The PHP environment is now set up, and the PHP file can be Put it into the htdocs folder and run

Pitfalls

1. After the browser enters the corresponding PHP address, it cannot parse php
Solution: In the command Enter httpd -t to check if there is a startup problem with Apache , as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
You can see that the error message is that the php7apache2_4.dll file in the PHP installation directory cannot be found. After checking online, the PHP version I downloaded is wrong. I should download the Thread safe version.

Introduction: Summary in Windows environmentBuilding a PHP development environment (Apache PHP MySQL)


2. Unzip the compressed package. It is best to put it in the root directory of the disk, otherwise it is easy to report a path error during configuration. I have changed the folder name here to facilitate future configuration, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Install PHP

1. Download the PHP compressed package at: https://windows.php.net/download. I downloaded the PHP7.0 Thread Safe version, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
2. Unzip the compressed package. I unzipped it as follows:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Install MySQL

1. The MySQL55 version I installed, the installation of MySQL will not be introduced here. Method, you can search online
2. MySQL official download address: https://dev.mysql.com/downloads/installer/
3. MySQL default installation directory is as follows:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configuring MySQL

1. Check in the environment variable page
The specific operations are as follows: My Computer-right-click-Properties-Advanced System Settings-Environment Variables
2. Create a new MYSQL_HOME variable, value It is the installation path of MySQL, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Edit the path system variable and add %MYSQL_HOME%\bin to the end of the path variable
4. Start MySQL and enter: start on the command line mysqld, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configure PHP

1. Open the PHP installation directory and copy php.ini-development first, then change php.ini-development to php.ini and save it
2. Open php. ini modify the configuration and search; extension_dir = "ext", change to extension_dir = "ext directory", for example extension_dir = "D:\Software\php7\ext", as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Open several commonly used extensions, for example: find extension=php_mysqli.dll and remove the preceding semicolon. Open the libraries in the picture below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

Configuring Apache

1. Open the installation directory of Apache, find the httpd.conf file in the conf folder and open it
2. Find the "Define SRVROOT" item and change the value in the quotation marks to the installation directory of Apache, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
3. Add support for PHP and The installation path of PHP is as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
The code is as follows:

# php7 supportLoadModule php7_module "D:/软件/php7/php7apache2_4.dll"AddType application/x-httpd-php .php .html .htm# configure the path to php.iniPHPIniDir "D:/软件/php7"
Copy after login
Copy after login

Start the Apache service

1. Set environment variables
Right-click My Computer, Properties ->Advanced, find the environment variable button at the bottom, select the current user's PATH variable, edit and create the following entries:
D:\Apache24\bin
D:\Software\php7
D:\Software \php7\ext
2. Install the apache service
Open the command line as an administrator and execute httpd.exe -k install
3. Start the service
Find the bin folder in the apache installation directory , double-click ApacheMonitor.exe, and apache will start after double-clicking.
You can select the icon below in the taskbar, right-click to open the Apache Service Monitor window, and manage the Apache service
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
4. At this time, enter localhost in the browser address bar and press Enter. The apache interface appears, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
5. Next, create a new phpinfo.php file in the Apache installation directory/htdocs directory, with the content:

Copy after login
Copy after login

After saving, Enter 127.0.0.1/phpinfo.php in the browser, press Enter, and the version information about PHP will appear, as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)

The PHP environment is now set up, and the PHP file can be Put it into the htdocs folder and run

Pitfalls

1. After the browser enters the corresponding PHP address, it cannot parse php
Solution: In the command Enter httpd -t to check if there is a startup problem with Apache , as shown below:
How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial)
You can see that the error message is that the php7apache2_4.dll file in the PHP installation directory cannot be found. After checking online, the PHP version I downloaded is wrong. I should download the Thread safe version.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to set up a PHP development environment (Apache+PHP+MySQL) (with tutorial). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!