Home>Article>Backend Development> Detailed explanation of the installation and configuration of PHP7 under win7

Detailed explanation of the installation and configuration of PHP7 under win7

藏色散人
藏色散人 Original
2020-08-24 10:20:15 5002browse

How to install and configure PHP7: first download "php-7.2.21-Win32-VC15-x64.zip"; then extract it to the "D:\wamp\php7.2" directory; then modify "php. ini" file; finally enable the curl extension and configure apache.

Detailed explanation of the installation and configuration of PHP7 under win7

# Recommended: "

PHP Video Tutorial

1, PHP installation

1), environment installation directory:

C:/wamp/ |——php |——php7.2 |——Apache24 |——mysql |——www

2), download

Linux only: http ://www.php.net/downloads.php

Special for windows: http://windows.php.net/download/

There are many versions of Windows on the official website. Which version to choose?

    If PHP runs in FAST-CGI or PHP-FPM mode, select the Non-Thread Safe (NTS) version
  • Usually for Apache PHP under Windows, select TS, IIS (fast-cgi) Choose NTS for PHP, choose NTS for Nginx PHP
  • Usually choose TS for Apache PHP under Linux, choose NTS for Nginx PHP
The apache php combination used in this article, so choose the ts (Thread Safe) version . Choose x64 or x86 depending on the operating system.

Most versions of PHP are compiled using VC9, VC11 or VC14 (compiled by Visual Studio 2008, 2012 or 2015 respectively), so you need to install the VC runtime environment on your computer.

The computer requires VC running environment:

    VC9 x86: http://www.microsoft.com/en-us/download/details.aspx?id=5582
  • VC9 x64: http://www.microsoft.com/en-us/download/details.aspx?id=15336
  • VC11 x86 or x64: http://www.microsoft.com/ en-us/download/details.aspx?id=30679
  • VC14 x86 or x64: http://www.microsoft.com/en-us/download/details.aspx?id=48145
  • 3), Installation and configuration

Take phpphp-7.2.21-Win32-VC15-x64.zip as an example.

After downloading, extract it to the D:\wamp\php7.2 directory.

Copy a copy of the php.ini-development file and rename it to php.ini.

Need to modify the following places:

Change the custom extension directory.

Find
;extension_dir = "ext", change to

extension_dir = "C:\wamp\php7.2\ext"

Tips: When used with apache, the absolute position needs to be written. Otherwise the extension cannot be loaded.

Enable curl extension

Then find:
;extension=curl, remove the semicolon:extension=curl.

Remove some comments:

extension=bz2 extension=curl extension=fileinfo extension=gd2 extension=gettext extension=mbstring extension=mysqli extension=openssl extension=pdo_mysql extension=soap extension=sockets extension=sqlite3 extension=tidy extension=xmlrpc extension=xsl

Set the default time zone

date.timezone=PRC

Add custom extensions

;[memcache] extension=php_memcache.dll
;[redis] extension=php_redis.dll

3), configure apache support php7.2

Find the apache configuration file, such as

C:\amp\Apache24\conf\httpd.conf, opena with an editor, and load the PHP7.2 module (
Add content, pay attention to the absolute path)

LoadModule php7_module C:\wamp\php7.2\php7apache2_4.dll  PHPIniDir "C:\wamp\php7.2\" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 

The diagram is as follows:


Detailed explanation of the installation and configuration of PHP7 under win7

b,

Modify thewww directory (this directory That is, the directory where the project is located, which can be accessed by the browser):

DocumentRoot "D:/wamp/www" 
The diagram is as follows:


Detailed explanation of the installation and configuration of PHP7 under win7c. Open the virtual host:
Remove the comment symbol
Detailed explanation of the installation and configuration of PHP7 under win7#d. Configure virtual host default information
Open
C:\Apache24\conf\extra\httpd-vhosts.conf file

DocumentRoot "D:\www"  Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Require all granted 

The picture is as follows:


Detailed explanation of the installation and configuration of PHP7 under win7e. Configure the domain name

 DocumentRoot "D:\www\tp5_test\public" ServerName www.tp5.com ServerAlias  Options FollowSymLinks ExecCGI AllowOverride All Require all granted 

The diagram is as follows:


Detailed explanation of the installation and configuration of PHP7 under win7##4), httpd-vhosts syntax error

After configuring the virtual host, syntax problems sometimes occur. How to accurately locate them? Enter the

httpd -t

command in the dos command line, and the syntax check will be performed. If there is no problem, syntx success will be reported:
Detailed explanation of the installation and configuration of PHP7 under win7If there is a problem, there will be Tips, just troubleshoot according to the tips.

5)、apache以CGI/FastCGI启动php7.2

注释掉3)a、加载PHP7.2模块中开启的配置,如下所示:
Detailed explanation of the installation and configuration of PHP7 under win7
然后,开启LoadModule fcgid_module modules/mod_fcgid.so,如下:
Detailed explanation of the installation and configuration of PHP7 under win7
接下来,添加配置信息:

 FcgidIOTimeout 60 FcgidConnectTimeout 30 FcgidMaxProcesses 8 FcgidOutputBufferSize 64 ProcessLifeTime 240 FcgidMaxRequestsPerProcess 500 FcgidMinProcessesPerClass 0 Options ExecCGI AddHandler fcgid-script .php #你项目php安装目录 FcgidWrapper "C:/wamp/php7.2/php-cgi.exe" .php

汇总如下:
Detailed explanation of the installation and configuration of PHP7 under win7
最后,写PHP脚本,代码为

如果出现以下内容代表配置成功:
Detailed explanation of the installation and configuration of PHP7 under win7

The above is the detailed content of Detailed explanation of the installation and configuration of PHP7 under win7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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