Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Windows Server 2016 server configuration guide: how to build a PHP7 running environment

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the Windows Server 2016 server configuration guide how to build PHP7 operating environment, the article is very detailed, has a certain reference value, interested friends must read it!

Because PHP7 already provides full 64bit support in Windows, choosing a 64bit system to install 64bit PHP7 will get better performance.

PHP7 needs VC14 (Visual C++ Redistributable for Visual Studio 2015 x86 or x64) as the runtime, so we need to install VC14 first.

Therefore, based on the installation of IIS, this article introduces the steps of PHP installation and configuration:

The first step is to download the PHP installation package and configure php.ini

1. Download PHP installation package: (PHP download address: http://windows.php.net/download/). Take the latest PHP 7.2.0 as an example. The latest PHP has four versions, 32-bit VC15 x86 Non Thread Safe / VC15 x86 Thread Safe and 64-bit VC15 x64 Non Thread Safe / VC15 x64 Thread Safe. If you want to use it for IIS, you need to install Non Thread Safe version, that is, the downloaded file with nts.

If the operating system is 64-bit and the configuration is OK, try to choose 64-bit, that is, choose to install php-7.2.0-nts-Win32-VC15-x64.zip, if you choose 32-bit, you can choose to install php-7.2.0-nts-Win32-VC15-x86.zip.

Download and install the runtime:

X64 installs 64-bit runtime, x86 installs 32-bit runtime.

32-bit download: https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe

64-bit download: https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe

Download PHP7

What is listed here is PHP 7.0.3 without safe threads. For other versions, you can go to: PHP For Windows.

32-bit download: http://windows.php.net/downloads/releases/php-7.0.3-nts-Win32-VC14-x86.zip

64-bit download: http://windows.php.net/downloads/releases/php-7.0.3-nts-Win32-VC14-x64.zip

3. Decompress and set up PHP7

1. Create a php directory on disk C.

2. Extract the downloaded PHP file to C:\ php

3. Let Windows display the file suffix, etc., and click to view-- click on the two items shown in the following figure.

4. Copy php.ini-production and rename it to php.ini

5. Modify the PHP.ini parameter, open it with notepad and modify it (encounter; delete it is activation! ):

① sets the php module path

Extension_dir = "C:\ php\ ext"

② sets the php time zone

Date.timezone = Asia/Shanghai

③ opens the php short tag

Delete all the `;` under short_open_tag

④ runs PHP in fast-CGI mode

Cgi.force_redirect = 0

Fastcgi.impersonate = 1

Cgi.rfc2616_headers = 1

⑤ opens the PHP module on demand

Generally speaking, both GD and curl pdo_mysql are needed.

Fourth, check whether it is running normally.

Run from the command prompt (cmd)

Cd C:\ php

Php-v

5. Set PHP in IIS

Go to the IIS control panel and select the home page, and click Handler Mapping

Click add Module Mapping

Enter the following:

Request path: * .php

Module: FastCgiModule

Executable file (optional): C:phpphp-cgi.exe

Name: FastCgi

If there is no FastCgiModule module, make sure that CGI is installed when you install IIS before.

Click Yes

Click FastCGI Settings

Change the monitoring changes to the absolute location where the php.ini file is located, C:\ php\ php.ini, by modifying as shown below.

Add to the aggregation Editor:

Name:PHP_FCGI_MAX_REQUESTS

Value:1000

5. In the IIS control panel, click default documents to create a new file called "index.php" under the default site.

Try to run the PHP document

Add probe and phpinfo to your site directory and check the operation:

The opening of the Windows Server 2016 server configuration guide Zend OPcache acceleration

Zend OPcache is PHP's son bytecode accelerator, which is currently the best in terms of compatibility and performance. Especially on PHP7, it's really a waste of resources if you don't turn on OPcache.

Open php.ini with notepad and add the following:

[Zend OPcache]

Zend_extension = php_opcache.dll

Opcache.memory_consumption=128

Opcache.optimization_level=1

Opcache.interned_strings_buffer=8

Opcache.max_accelerated_files=4096

Opcache.revalidate_freq=60

Opcache.fast_shutdown=1

Opcache.enable=1

Opcache.enable_cli=1

Here is the recommended configuration. If you have the ability, you can configure it according to the official documentation of PHP: Zend Opcache configuration information.

Then save it and ok it.

These are all the contents of the article "how to build a PHP7 runtime environment in the Windows Server 2016 server configuration guide". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report