Install PHP development environment under Windows

In order to start using PHP, several conditions need to be met:

   ①Web host that supports PHP and MySQL

   ② Install Web server, PHP, database (such as MySQL)

 

【Installation method】

There are two main types: (1) self-configuration; (2) PHP server components/packages;

 

(1) Self-configuration

  、 、 Apache

      Because the Apache official website 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. Enter the official download address of Apachelounge: http://www.apachelounge.com/download/

      First download and install vc redist , a component required for Apache to run .

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

Modify the configuration file:

   ①Apache default exists in the path: "c:\Apache24" (the version number may be different). If it is different from your installation path, you need to open the Apache\conf\httpd.conf configuration file and put all "c:\Apache24", "c:\Apache24\htdocs" and "c :\Apache24\cgi-bin\" to the corresponding path.

   ② Specify IP and port: find "ServerName www.example.com:80" in httpd.conf, remove the previous comment, and change "www.example.com" to "localhost". If you want to modify the port, modify this "80" together with the 80 in the previous "Listen: 80".

   ③(Optional) Add system variable: Add "Apache installation path\bin" to Path

Verify that the installation was successful:

    Run Apache to start httpd.exe. Enter localhost:80 on the browser, if it is not inaccessible, then the Apache configuration is complete

 

  2. PHP

   ①Install and configure PHP

   Go to the PHP download address http://windows.php.net/download to download the latest thread-safe 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 previously installed vc redist version

    Enter the PHP installation directory, copy a copy of php.ini-development and rename it to php.ini and put it in the installation path, open it and find "extension_dir", remove the comment, and change the value to "PHP installation path\ext"

   ②Load PHP in Apache

   Open Apache's configuration file conf\httpd.conf, find the LoadModule area, and add: LoadModule php7_module "PHP installation path\php7apache2_4.dll" # Load PHP as a module in Apache, "7" in "php7_module" It should correspond to the version of PHP;

   Also, different PHP versions "php7apache2_4.dll" may be different. PHPIniDir "PHP installation path" # Tell Apache PHP installation path

    ③ Define the file that executes the PHP module

    Find AddType application/x-gzip .gz .tgz and add the code on the next line: AddType application/x-httpd-php .php .html: declare that .php and .html files can execute PHP programs

    ④Test

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

<?php  phpinfo(); ?>

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

 

3. MySQL

   Install:

   Download the corresponding installation version at https://dev.mysql.com/downloads/ and install it according to your own needs.

   Load the assembly to connect to MySQL in PHP:

    Add a line of extension=php_mysqli.dll to 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. Write what you want here. Different assemblies may use different functions when connecting to the database

   test:

   Edit in test.php:

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

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

 

(2) PHP server component (combination package)

      For beginners, it is recommended to use the integrated server component, which already includes services such as PHP, Apache, Mysql, etc., eliminating the need for developers to spend time in the tedious process of configuring the environment.

 

   【Introduction】

    PHP server component (combination package): It is to package and process server software and tools such as Apache, PHP, and MySQL after the installation is complete.

Developers only need to extract the configured package to the local hard disk and use it without additional configuration. The combination package realizes the rapid construction of the PHP development environment. For programmers who are just starting to learn PHP, this method is recommended to build a PHP development environment. Although the combination package is much less flexible, its installation is simple, the speed is fast, and the operation is stable, so it is more suitable for beginners to use. 

 

  【Type of combination package】

   There are many popular combination packages on the Internet, such as WampServer, EasyPHP, AppServ and XAMPP.

There are 3 packages recommended here: EasyPHP, AppServ and XAMPP. For beginners, EasyPHP or AppServ is recommended, while XAMPP is more complicated.

(1) The AppServ combination package I use here, I will summarize the detailed explanation in the later article Combination Package Building PHP Environment Tutorial

(2)WampServer

         Window system can use WampServer, download address: http://www.wampserver.com/, supports 32-bit and 64-bit systems, select the version according to your own system.

WampServer installation is also simple, you just need to keep clicking "Next" to complete the installation.

(2)XAMPP

         XAMPP supports Mac OS and Window system, download address: https://www.apachefriends.org/zh_cn/index.html

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326180879&siteId=291194637
Recommended