php configuration step description

The difference between php thread safety and non-thread safety difference between TS and NTS

TS: Thread Safe thread safety, thread (Thread) safety check will be performed during execution

NTS: Non Thread Safe Non-thread safe, no thread (Thread) safety check is performed during execution

 

When I use Apache+PHP mode, I usually load PHP into apache as a Module, then in the working mode of apache parent process-multi-child process, thread safety check is required, so if it is executed in this way php, select ts version

 

Then if you are using fastcgi, for example, using php-fpm to manage php execution, you do not need to perform thread safety checks, then choose the nts version of php

 

PHP configuration steps

1. Copy C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.ini-production and rename it to php.ini;

2. Open C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.ini with Notepad and change; extension_dir = "ext" to extension_dir = "ext" (remove the points in front of extension No)

3. Modify ;extension=php_mbstring.dll to extension=php_mbstring.dll (remove the semicolon in front of extension, this is a php multi-byte string extension) All exts that need to be used can be opened

 

extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_pdo_sqlsrv_55_ts.dll

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll

;extension=php_soap.dll
;extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dll

 

other settings

4. Time Search for "date.timezone" and find: ;date.timezone = first go to the previous semicolon and then change to date.timezone = PRC

test

 

date_default_timezone_set('Asia/Shanghai');//'Asia/Shanghai' Asia/Shanghai
date_default_timezone_set('Asia/Chongqing');//Asia/Chongqing' is "Asia/Chongqing"
date_default_timezone_set('PRC');//where PRC is "People's Republic of China"

 5. Search for "cgi.force_redirect"; cgi.force_redirect = 1 go to the previous semicolon and then change to cgi.force_redirect = 0

; Root path of PHP pages, only valid if non-empty.
; If PHP was not compiled with FORCE_REDIRECT, if you are running php as CGI under any web server (except IIS), you must set doc_root
; see documentation for security issues . An alternative is to use the following cgi.force_redirect
doc_root =

; On most web servers, cgi.force_redirect is necessary to provide secure execution of PHP as CGI.
; If not configured, PHP will enable this by default.
; You can disable this here and ; Use at your own risk
; **You can safely disable this in IIS, in fact, you must.**
; cgi.force_redirect = 1

; If cgi.nph is enabled, forces CGI to send Status: 200 on every request.
; cgi.nph = 1

; If cgi.force_redirect is turned on and you are not running under an Apache or Netscape (iPlanet) web server,
; you may need to set an environment variable name for PHP to look for and get it to continue execution. Setting this variable may cause security risks problem, please understand the possible consequences before setting.

 

6. Set the upload file size

Form post submission maximum content 4G

post_max_size = 4096M

Set maximum upload file size

 

 

upload_max_filesize = 1024M

  

7. Turn on code acceleration

1. Open the php.ini file

2. Find: [opcache], set to:

 

[opcache]
; dll address
zend_extension=php_opcache.dll
; switch on
opcache.enable=1
; start CLI
opcache.enable_cli=1
; Available memory, as appropriate, in Mb
opcache.memory_consumption=528
; Zend Optimizer + total amount of memory for strings in the scratch pool. (unit: MB)
opcache.interned_strings_buffer=8
; For the multi-cache file limit, if the hit rate is less than 100%, you can try to increase this value
opcache.max_accelerated_files=10000
; Opcache will check the modification time of the file within a certain period of time, here is the time period for checking, the default is 2, and the positioning is seconds
opcache.revalidate_freq=1
; Turn on fast shutdown, turning this on will increase the speed of reclaiming memory during PHP Request Shutdown
opcache.fast_shutdown=1
 

8.memcached configuration

Memcached is a high-concurrency in-memory key-value pair cache system. Its main function is to cache database query results, content, and other time-consuming calculation results in system memory, thereby accelerating the response speed of web applications.

Memcached was originally used as a Linux application installed on Linux servers, but since open source it has been recompiled for Windows environments. Both Jellycan and Northscale sites provide binary executable file downloads for Windows. The following is the download address:

     http://code.jellycan.com/files/memcached-1.2.5-win32-bin.zip

  http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip

  http://downloads.northscale.com/memcached-win32-1.4.4-14.zip

  http://downloads.northscale.com/memcached-win64-1.4.4-14.zip

  http://downloads.northscale.com/memcached-1.4.5-x86.zip

  http://downloads.northscale.com/memcached-1.4.5-amd64.zip

 

https://pecl.php.net/package/memcache/3.0.8/windows

DLL List PHP 5.6 PHP 5.5 PHP 5.4 PHP 5.3
5.6 Non Thread Safe (NTS) x86
5.6 Thread Safe (TS) x86
5.6 Non Thread Safe (NTS) x64
5.6 Thread Safe (TS) x64
5.5 Non Thread Safe (NTS) x86
5.5 Thread Safe (TS) x86
5.5 Non Thread Safe (NTS) x64
5.5 Thread Safe (TS) x64
5.4 Non Thread Safe (NTS) x86
5.4 Thread Safe (TS) x86
5.3 Non Thread Safe (NTS) x86
5.3 Thread Safe (TS) x86

       php7+ version dll download  https://github.com/nono303/PHP7-memcache-dll

Before version 1.4.5, memcached could be installed as a service, but this feature was removed in later versions. Therefore, the installation of memcached can be divided into two categories, the first is the version before 1.4.5, and the other is the version after 1.4.5.

Install memcached < 1.4.5:

  1. Unzip the downloaded file to any directory.

 

  2. Versions of memcached prior to 1.4.5 will be installed as a service, open the console as administrator, and run the following command:

 

c:\memcached\memcached.exe -d install
       Note that replace the path c:\memcached\memcached.exe with your local installation path.

 

  3. Then use the following commands to start or stop the memcached service:

 

c:\memcached\memcached.exe -d start
c:\memcached\memcached.exe -d stop
     4. Modify memcached configuration items through registry keys. Enter regedit.exe in Run and navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached". Modify the key value in it. For example, if you want to increase the maximum memory limit used by memcached, you can modify the value of ImagePath:

 

 

"c:\memcached\memcached.exe" -d runservice -m 512
    * In addition to the parameter '-m 512', you can also use other parameters. All available parameters can be viewed through "c:\memcached\memcached.exe -h".

 

  5. If you want to uninstall the memcached service, you can use the following command:

 

c:\memcached\memcached.exe -d uninstall
  install memcached >= 1.4.5

 

  1. Unzip the downloaded file to any directory.

  2. Versions of memcached after 1.4.5 cannot run as a Windows service, you must use Windows Scheduled Tasks to run it. To configure memcached to run automatically when Windows starts, run the following command at the command line:

 

schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 512"
       * Note to replace the path c:\memcached\memcached.exe with your local installation path.

 

       ** In addition to the parameter '-m 512', you can also use other parameters. All available parameters can be viewed through "c:\memcached\memcached.exe -h".

  3. Remove memcached from Windows Scheduler with the following command:

 

schtasks /delete /tn memcached
 

 

Modify the php.ini file to append the following code at the bottom

 

[memcache]
extension=php_memcache.dll
; A high-performance distributed memory object cache system, by maintaining a unified huge hash table in memory,
; It can be used to store data in various formats, including images, videos, documents, and database retrieval results.
; Whether to transparently failover to other servers in the event of errors.
memcache.allow_failover = 0
; The maximum number of servers to try when accepting and sending data, only valid when memcache.allow_failover is enabled.
memcache.max_failover_attempts = 20
;Data will be transferred according to the block size set by this value. Smaller values ​​require more additional network transfers.
; If you notice unexplained slowdowns, try increasing this value to 32768.
memcache.chunk_size = 8192
; Default TCP port to use when connecting to the memcached server.
memcache.default_port = 11211
; Controls the strategy for mapping keys to servers. The default value "standard" means to use the old hashing strategy of the previous version.
;Set to "consistent" to allow adding/removing servers from the connection pool without having to recalculate the mapping between keys and servers.
memcache.hash_strategy = "consistent"
; Controls the hash function that maps keys to servers. The default value "crc32" uses the CRC32 algorithm, while "fnv" indicates the use of the FNV-1a algorithm.
;FNV-1a is slightly slower than CRC32, but hashes better.
memcache.hash_function = "crc32"
;The following 2 settings are shown in the above [session]
; Mark to use memcache as session handler when the value is memcache
;session.save_handler = "files"
;Define the separator for each server link used for call storage, for example: "tcp://host1:11211, tcp://host2:11211"
; each server link can contain parameters that are accepted for that server, similar to servers added using Memcache::addServer()
;例如:“tcp://host1:11211?persistent=1&weight=1&timeout=1& amp;retry_interval=15”
;session.save_path = ""
 restart php

 

 

Open cmd and run C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.exe to see if it is normal 

 

PHP configuration steps

1. Copy C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.ini-production and rename it to php.ini;

2. Open C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.ini with Notepad and change; extension_dir = "ext" to extension_dir = "ext" (remove the points in front of extension No)

3.将;extension=php_mbstring.dll 修改为 extension=php_mbstring.dll(去掉extension前面的分号,这是php多字节字符串扩展) 需要用到的ext都可以开起来

 

extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_pdo_sqlsrv_55_ts.dll

; The MIBS data available in the PHP distribution must be installed. 
; See http://www.php.net/manual/en/snmp.installation.php 
;extension=php_snmp.dll

;extension=php_soap.dll
;extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dll

 

其他设置

4.时间 搜索“date.timezone”,找到:;date.timezone = 先去前面的分号再改为 date.timezone = PRC

测试

 

date_default_timezone_set('Asia/Shanghai');//'Asia/Shanghai' 亚洲/上海
date_default_timezone_set('Asia/Chongqing');//其中Asia/Chongqing'为“亚洲/重庆”
date_default_timezone_set('PRC');//其中PRC为“中华人民共和国”

 5.搜索“cgi.force_redirect” ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

; PHP页面的根路径, 只有非空时有效.
; 如果PHP没有使用FORCE_REDIRECT来编译, 如果你将php作为CGI运行在任何web服务器下(除了IIS)的话,你必须设置doc_root
; 针对安全问题查看文档. 一种替代方案是使用下面的cgi.force_redirect
doc_root =

; 在绝大多数web服务器下,cgi.force_redirect 对于提供安全执行PHP作为CGI来说是很有必要的.
; 没有配置的情况下,PHP会默认打开此项.
; 你可以在这里关闭此项并且自己承担风险
; **你可以在IIS安全的关闭此项,事实上,你必须关闭此项.**
; cgi.force_redirect = 1

; 如果 cgi.nph 被打开,就会强制CGI在每个请求时发送Status: 200.
; cgi.nph = 1

; 如果cgi.force_redirect被打开,并且你没有在Apache或者Netscape(iPlanet) web服务器下运行,
; 你也许需要设置一个环境变量名让PHP来查找让其可以获取后继续执行. 设置此变量可能引起安全问题, 在设置之前请先了解可能引起的后果.

 

6.设置上传文件大小

表单post提交最大内容4G

post_max_size = 4096M

设置最大上传文件大小

 

 

upload_max_filesize = 1024M

  

7.开启代码加速

1、打开php.ini文件

2、找到:[opcache],设置为:

 

[opcache]
; dll地址
zend_extension=php_opcache.dll
; 开关打开
opcache.enable=1
; 开启CLI
opcache.enable_cli=1
; 可用内存, 酌情而定, 单位为:Mb
opcache.memory_consumption=528
; Zend Optimizer + 暂存池中字符串的占内存总量.(单位:MB)
opcache.interned_strings_buffer=8
; 对多缓存文件限制, 命中率不到 100% 的话, 可以试着提高这个值
opcache.max_accelerated_files=10000
; Opcache 会在一定时间内去检查文件的修改时间, 这里设置检查的时间周期, 默认为 2, 定位为秒
opcache.revalidate_freq=1
; 打开快速关闭, 打开这个在PHP Request Shutdown的时候回收内存的速度会提高
opcache.fast_shutdown=1
 

8.memcached的配置

Memcached是一个高并发的内存键值对缓存系统,它的主要作用是将数据库查询结果,内容,以及其它一些耗时的计算结果缓存到系统内存中,从而加速Web应用程序的响应速度。

Memcached最开始是作为Linux应用程序被安装在Linux服务器上来使用的,不过自从开源之后,它又被重新编译以适用于Windows环境。Jellycan和Northscale两个站点都提供了Windows的二进制可执行文件下载,下面是下载的地址:

     http://code.jellycan.com/files/memcached-1.2.5-win32-bin.zip

  http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip

  http://downloads.northscale.com/memcached-win32-1.4.4-14.zip

  http://downloads.northscale.com/memcached-win64-1.4.4-14.zip

  http://downloads.northscale.com/memcached-1.4.5-x86.zip

  http://downloads.northscale.com/memcached-1.4.5-amd64.zip

 

https://pecl.php.net/package/memcache/3.0.8/windows

DLL List PHP 5.6 PHP 5.5 PHP 5.4 PHP 5.3
5.6 Non Thread Safe (NTS) x86
5.6 Thread Safe (TS) x86
5.6 Non Thread Safe (NTS) x64
5.6 Thread Safe (TS) x64
5.5 Non Thread Safe (NTS) x86
5.5 Thread Safe (TS) x86
5.5 Non Thread Safe (NTS) x64
5.5 Thread Safe (TS) x64
5.4 Non Thread Safe (NTS) x86
5.4 Thread Safe (TS) x86
5.3 Non Thread Safe (NTS) x86
5.3 Thread Safe (TS) x86

       php7+ version dll download  https://github.com/nono303/PHP7-memcache-dll

Before version 1.4.5, memcached could be installed as a service, but this feature was removed in later versions. Therefore, the installation of memcached can be divided into two categories, the first is the version before 1.4.5, and the other is the version after 1.4.5.

Install memcached < 1.4.5:

  1. Unzip the downloaded file to any directory.

 

  2. Versions of memcached prior to 1.4.5 will be installed as a service, open the console as administrator, and run the following command:

 

c:\memcached\memcached.exe -d install
       Note that replace the path c:\memcached\memcached.exe with your local installation path.

 

  3. Then use the following commands to start or stop the memcached service:

 

c:\memcached\memcached.exe -d start
c:\memcached\memcached.exe -d stop
     4. Modify memcached configuration items through registry keys. Enter regedit.exe in Run and navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached". Modify the key value in it. For example, if you want to increase the maximum memory limit used by memcached, you can modify the value of ImagePath:

 

 

"c:\memcached\memcached.exe" -d runservice -m 512
    * In addition to the parameter '-m 512', you can also use other parameters. All available parameters can be viewed through "c:\memcached\memcached.exe -h".

 

  5. If you want to uninstall the memcached service, you can use the following command:

 

c:\memcached\memcached.exe -d uninstall
  install memcached >= 1.4.5

 

  1. Unzip the downloaded file to any directory.

  2. Versions of memcached after 1.4.5 cannot run as a Windows service, you must use Windows Scheduled Tasks to run it. To configure memcached to run automatically when Windows starts, run the following command at the command line:

 

schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 512"
       * Note to replace the path c:\memcached\memcached.exe with your local installation path.

 

       ** In addition to the parameter '-m 512', you can also use other parameters. All available parameters can be viewed through "c:\memcached\memcached.exe -h".

  3. Remove memcached from Windows Scheduler with the following command:

 

schtasks /delete /tn memcached
 

 

Modify the php.ini file to append the following code at the bottom

 

[memcache]
extension=php_memcache.dll
; A high-performance distributed memory object cache system, by maintaining a unified huge hash table in memory,
; It can be used to store data in various formats, including images, videos, documents, and database retrieval results.
; Whether to transparently failover to other servers in the event of errors.
memcache.allow_failover = 0
; The maximum number of servers to try when accepting and sending data, only valid when memcache.allow_failover is enabled.
memcache.max_failover_attempts = 20
;Data will be transferred according to the block size set by this value. Smaller values ​​require more additional network transfers.
; If you notice unexplained slowdowns, try increasing this value to 32768.
memcache.chunk_size = 8192
; Default TCP port to use when connecting to the memcached server.
memcache.default_port = 11211
; Controls the strategy for mapping keys to servers. The default value "standard" means to use the old hashing strategy of the previous version.
;Set to "consistent" to allow adding/removing servers from the connection pool without having to recalculate the mapping between keys and servers.
memcache.hash_strategy = "consistent"
; Controls the hash function that maps keys to servers. The default value "crc32" uses the CRC32 algorithm, while "fnv" indicates the use of the FNV-1a algorithm.
;FNV-1a is slightly slower than CRC32, but hashes better.
memcache.hash_function = "crc32"
;The following 2 settings are shown in the above [session]
; Mark to use memcache as session handler when the value is memcache
;session.save_handler = "files"
;Define the separator for each server link used for call storage, for example: "tcp://host1:11211, tcp://host2:11211"
; each server link can contain parameters that are accepted for that server, similar to servers added using Memcache::addServer()
;例如:“tcp://host1:11211?persistent=1&weight=1&timeout=1& amp;retry_interval=15”
;session.save_path = ""
 restart php

 

 

Open cmd and run C:\www\tools\php-5.6.29-nts-Win32-VC11-x64\php.exe to see if it is normal 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326637993&siteId=291194637