On Windows computers, there are many ways to deploy PHP applications. Three commonly used methods will be introduced below.
Method 1: Use XAMPP
XAMPP is an easy-to-install and use PHP development environment that includes Apache, MySQL, PHP and Perl. XAMPP allows you to quickly set up a web server and is ideal for developing and testing PHP applications.
1. Download XAMPP and install
Visit the XAMPP official website https://www.apachefriends.org to download the installation package and install it. During the installation process, you can choose to install components such as Apache, MySQL, and PHP.
2. Configure Apache
After installing XAMPP, open the XAMPP control panel, start the Apache service, and access localhost in the browser. If the XAMPP welcome page is displayed, it means that Apache has run successfully .
To make Apache support PHP, you need to edit Apache's configuration file httpd.conf. You can click the configuration file button in the Apache module of the control panel to edit.
Find "LoadModule php7_module" and remove the preceding comment character "#", save and exit.
Find "AddHandler application/x-httpd-php .php" and remove the preceding comment character "#", save and exit.
3. Copy the PHP application to the htdocs directory
In the XAMPP installation directory, there is a directory named htdocs, which is the default Web root directory of Apache. Copy the PHP application to the htdocs directory and access it through the browser.
4. Access the PHP application in the browser
Access localhost/yourapp through the browser, where yourapp is the name of the application. If everything is fine, you can see the interface or output of the application.
Method 2: Use WAMP
WAMP is similar to XAMPP. It is also a simple and easy-to-use Web server integrated environment. It includes components such as Apache, MySQL and PHP.
1. Download WAMP and install it
Visit WAMP official website https://www.wampserver.com/en to download the installation package and install it. During the installation process, you can choose to install components such as Apache, MySQL, and PHP.
2. Configure Apache
Similar to XAMPP, you need to edit Apache's configuration file httpd.conf, find "LoadModule php7_module" and "AddHandler application/x-httpd-php.php" and remove them The preceding comment character "#".
3. Copy the PHP application to the www directory
The default Web root directory of WAMP is the www directory, which can be found in the WAMP installation directory. Copy the PHP application to the www directory and access it through the browser.
4. Access the PHP application in the browser
Access localhost/yourapp through the browser, where yourapp is the name of the application. If everything is normal, you can see the interface of the application or output.
Method 3: Manually deploy PHP applications
If you do not want to use integrated environments such as XAMPP or WAMP, you can also manually deploy PHP applications.
1. Install the Web server
First you need to install the Web server, such as Apache, IIS, etc. After the installation is complete, relevant configurations need to be performed, including virtual hosts, ports, etc.
2. Install PHP
Download the Windows version of PHP from the PHP official website http://www.php.net and install it.
3. Configure the Web server
PHP-related configuration information needs to be added to the Apache configuration file httpd.conf or IIS configuration file web.config. For example, for Apache, you need to add the following:
LoadModule php7_module "c:/php/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "c:/php "
Among them, php7_module needs to be modified accordingly according to the PHP version number and Apache version number. PHPiniDir specifies the PHP configuration file directory.
4. Copy the PHP application to the Web server directory
Copy the PHP application to the document root directory of the Web server, and you can access it through the browser.
Summary
There are many ways to deploy PHP applications, the most commonly used ones are using XAMPP, WAMP and manual deployment. Among them, XAMPP and WAMP can be used to quickly build a web server, which is very suitable for developing and testing PHP applications. Manual deployment requires more configuration and work, but is more flexible and customizable.
The above is the detailed content of How to deploy windows php (three common methods). For more information, please follow other related articles on the PHP Chinese website!