Home Backend Development PHP Problem How to install and configure php development environment under windows

How to install and configure php development environment under windows

Aug 05, 2020 pm 03:32 PM
php windows development environment

How to install and configure the php development environment under windows: 1. Download and install apache; 2. Edit the httpd.conf configuration file; 3. Download and install php; 4. Load php in apache; 5. Download and install mysql ;6. Load the assembly connecting to mysql in php.

How to install and configure php development environment under windows

Specific method:

(Recommended tutorial: php graphic tutorial)

1. apache

Because the official website of Apache only provides source code, if you want to use it, you must compile it yourself. Here I choose the third-party installation package Apache Lounge.

1. Go to Apachelounge official website to download.

2. First download and install vc redist, which is a component necessary for Apache to run (if it has already been installed, there is no need to install it again).

3. Download the decompressed version of Apache and place the decompressed folder in the path you want to install.

4. Modify the configuration file (Apache installation directory/conf/httpd.conf):

(1) Apache’s default existence path: “c:\Apache24” (the version number may be different) . If it is different from your installation path, you need to modify the path parameter configuration:

Define SRVROOT "你的Apache安装目录"
Copy after login

(2) Specify the IP and port (Apache default access: http://localhost/):

ServerName www.example.com:80
修改为
ServerName localhost
Copy after login

( 3) (Optional) Add system variables: Add "Apache installation path\bin" to Path.

(4) Verify whether the installation is successful: run Apache's startup program httpd.exe.

Enter localhost:80 on the browser. If it is not inaccessible, then the Apache configuration is complete.

(5) Installation service: Enter "Apache installation path\bin" under cmd, execute the command:

httpd -k install
Copy after login

2. PHP

1 , Install and configure PHP

(1) Download the latest thread-safe version of PHP zip 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.

(2) Enter the PHP installation directory, copy a copy of the php.ini-development file, rename it php.ini and put it in the installation path, open it and find "extension_dir", remove the comments, and change the value to "PHP Installation Path\ext" (very important).

2. Load PHP in Apache

Open Apache's configuration file conf\httpd.conf, find the LoadModule area, and add after it:

LoadModule php7_module "PHP安装路径\php7apache2_4.dll"  # 在Apache中以module的方式加载PHP,“php7_module”中的“7”要和PHP的版本对应;此外,不同的PHP版本“php7apache2_4.dll”可能不同。
Copy after login
PHPIniDir "PHP安装路径" #告诉Apache PHP的安装路径。
Copy after login

3. Define execution PHP module file

Look for AddType application/x-gzip .gz .tgz, and add code in the next line:

AddType application/x-httpd-php .php .html
Copy after login

States that .php and .html files can execute PHP programs.

4. Test

Create a new file under the Apache installation path\htdocs: test.php, edit it:

<?php      
    phpinfo(); 
?>
Copy after login

Start Apache, enter in the browser: localhost:80/test.php.

(Video tutorial recommendation: php video tutorial)

3. MySQL

1. Installation: Download the corresponding installation version , install according to your own needs.

2. 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.

3. Test

Edit in test.php:,

<?php      
    $mysqli = mysqli_connect("localhost","root","pwd") or die("cannt connet"); 
?>
Copy after login

Start the database, restart Apache, and check on the browser. If there is no error message, the configuration is correct. .

The above is the detailed content of How to install and configure php development environment under windows. For more information, please follow other related articles on the PHP Chinese website!

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 admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) Apr 08, 2025 am 12:03 AM

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

Solutions to the errors reported by MySQL on a specific system version Solutions to the errors reported by MySQL on a specific system version Apr 08, 2025 am 11:54 AM

The solution to MySQL installation error is: 1. Carefully check the system environment to ensure that the MySQL dependency library requirements are met. Different operating systems and version requirements are different; 2. Carefully read the error message and take corresponding measures according to prompts (such as missing library files or insufficient permissions), such as installing dependencies or using sudo commands; 3. If necessary, try to install the source code and carefully check the compilation log, but this requires a certain amount of Linux knowledge and experience. The key to ultimately solving the problem is to carefully check the system environment and error information, and refer to the official documents.

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

MySQL can't be installed after downloading MySQL can't be installed after downloading Apr 08, 2025 am 11:24 AM

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.

Unable to access mysql from terminal Unable to access mysql from terminal Apr 08, 2025 pm 04:57 PM

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

How to solve mysql cannot connect to local host How to solve mysql cannot connect to local host Apr 08, 2025 pm 02:24 PM

The MySQL connection may be due to the following reasons: MySQL service is not started, the firewall intercepts the connection, the port number is incorrect, the user name or password is incorrect, the listening address in my.cnf is improperly configured, etc. The troubleshooting steps include: 1. Check whether the MySQL service is running; 2. Adjust the firewall settings to allow MySQL to listen to port 3306; 3. Confirm that the port number is consistent with the actual port number; 4. Check whether the user name and password are correct; 5. Make sure the bind-address settings in my.cnf are correct.

See all articles