How to install php environment under windows

青灯夜游
Release: 2023-03-13 06:58:01
Original
23096 people have browsed it

Installation method: 1. Install and configure Apache; 2. Download and unzip the php installation package to the specified path; 3. Copy a copy of "php.ini-development" and rename it to "php.ini" for installation. path, configure the file; 4. Load PHP in Apache and define the file for executing the PHP module.

How to install php environment under windows

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Install PHP under Windows Development environment

1. Apache

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

  • Enter Apachelounge official download address: http://www.apachelounge.com/download/

  • First download and install vc redist, this It 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:

Apache’s default path 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 and c:\Apache24 that are not commented with "#" in front of it. \htdocs and c:\Apache24\cgi-bin\ are changed to the corresponding paths.

Specify IP and port: Find ServerName www.example.com:80 in httpd.conf, remove the previous comment, and replace "www.example.com "changed 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.

Tips: Register Apache as a Windows service

  • Install: apache’s bin directory Execute with administrator privileges

      httpd.exe -k install
    Copy after login
  • ##Uninstall: Execute with administrator privileges under the bin directory of apache

      httpd.exe -k uninstall
    Copy after login

2. PHP

  • Install and configure PHP
Enter the PHP download address http://windows. php.net/download 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.

Enter the PHP installation directory, copy a copy of

php.ini-development and rename it php.ini Place it in the installation path, open it and find ;extension_dir= ext, remove the comments and change the value to PHP installation path\ext.

    extension_dir = "D:/Program Files/php-7.2.10/ext"
Copy after login
  • Load PHP in Apache & define the file that executes the PHP module
Open the Apache configuration file conf\httpd.conf and find LoadModule Area, add after it:

           

LoadModule php7_module "PHP installation path\php7apache2_4.dll" # Load PHP as a module in Apache, the "7" in "php7_module" must be Corresponds 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>
Copy after login
    Test: Create a new file under Apache installation path\htdocs: test.php , edit inside:, start Apache, enter in the browser: localhost:80/test.php.
Recommended learning: "

PHP Video Tutorial"

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

Related labels:
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