Home > Backend Development > PHP Problem > How to install and configure PHP environment on Win system

How to install and configure PHP environment on Win system

PHPz
Release: 2023-04-06 11:26:02
Original
1239 people have browsed it

Before using PHP to develop applications, you need to install PHP on your computer and configure the Apache web server correctly. This tutorial will show you how to install and configure a PHP environment on Windows operating systems.

Step 1: Download PHP

First, you need to download the latest version of PHP from PHP’s official website https://windows.php.net/download/. Download the version you need (for this tutorial, we chose the Thread Safe version of PHP 7.4.16).

Step 2: Install PHP

After downloading PHP, unzip the file to install PHP on your computer. It is recommended to install it in the C:\php directory.

Step 3: Configure PHP

After you have PHP installed on your computer, you need to configure the Apache web server to use PHP. Locate the Apache web server's configuration file httpd.conf (default location: C:\Program Files\Apache Group\Apache2\conf\httpd.conf) and edit the file.

Find the following line:

#LoadModule php7_module modules/php7apache2_4.dll
Copy after login

Remove the comment symbol "#" and it becomes:

LoadModule php7_module “C:/php/php7apache2_4.dll”
Copy after login

Add the following content at the end of the file:

# PHP Settings
PHPIniDir "C:/php/"
AddHandler application/x-httpd-php .php
Copy after login

Save and close the file.

Step 4: Start the Apache Web server

Open the command prompt with administrator privileges and execute the following command to start the Apache Web server:

net start Apache2.4
Copy after login

Step 5: Test PHP

After completing the above steps, you can create a PHP file and place it in the Web directory of the Apache Web server (default location: C:\Program Files\Apache Group\Apache2\htdocs).

For example, create a file called info.php and enter the following:

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

Then enter the following URL in your web browser to access the info.php file:

http://localhost/info.php

If you have configured PHP correctly, you will be able to see the PHP configuration information page.

Conclusion

Now, you have successfully installed and configured a PHP environment on your Windows operating system. Next, you can develop web applications using PHP.

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

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template