这几天把空间和本地的php7.2版本都去除了,主要站点和程序都跑在了php7.4上面,因为这个版本已经出来几个月,但一直未使用和测试。经过这些天站点的运行及使用,感觉非常的稳定,速度上与php7.3相当,但是少了很多支持的组件,像wincache redis memcache等。相信年底12月正式版出来后,这方面的相关扩展也会发布相应版本。
php7.4的安装和配置跟之前没有分别,唯一要注意的一点是它的编译已经从vc++15 变成了vc++16,它的安装包命名也变成了vs16(visualstudio 16,即vs 2019),这样以后不再以vc命名,这点可能和微软的vc++版本集成到了 vs编辑器有关。
偶下载的最新版本是windows平台的 php-7.4.0beta2-nts-Win32-vs16-x64,如果环境未安装vc++16,那么你在打开里面的 php-cgi.exe 和 php.exe时,会闪一下自动关闭,安装后就正常了。
php7.4新特性非常多,这里只说一个非常实用而简单的,就是 opcache的preload(预加载),它能够直接让你的框架及插件载入内存,从而提高程序的响应速度,这点在wp平台是相当有用,感觉提升的速度是明显的,初次访问还是较慢,但第2次访问就快了许多。配置方面有点麻烦,它只能配置一个入口文件或项目,而且要写在php.ini的 opcache.preload= 里面。有兴趣的朋友可以试一下将你的整个php站点前端加载进去,目前还不清楚具体能加载多少文件目录和内存大小,至少偶这边能够加载一个插件的主文件或主题文件。
//2019.12.03
php7.4.0正式版本11月27日发布,刚刚用了不到一个星期,感觉非常稳定。
这里把偶的配置方法(多php版本)也写一下。
php版本目录的结构
php.ini配置
有些不用的扩展(redis wincache)暂时未开启
disable_functions = exec,eval,system,phpinfo,passthru,error_log,ini_alter,dl,openlog,syslog,readlink,symlink,link,leak,proc_open,popepassthru,chroot,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,popen
1disable_functions=exec,eval,system,phpinfo,passthru,error_log,ini_alter,dl,openlog,syslog,readlink,symlink,link,leak,proc_open,popepassthru,chroot,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,popen
extension_dir = "C:\Program Files\php\php7.4.x_x64\ext"
1extension_dir="C:\ProgramFiles\php\php7.4.x_x64\ext"
post_max_size = 600M
1post_max_size=600M
[PHP_EXIF]
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=12000
opcache.max_wasted_percentage=60
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.revalidate_path=0
opcache.save_comments=1
opcache.fast_shutdown=0
opcache.enable_file_override=0
opcache.optimization_level=0xffffffff
opcache.inherited_hack=1
opcache.dups_fix=0
opcache.blacklist_filename=
opcache.max_file_size=0
opcache.consistency_checks=0
opcache.force_restart_timeout=180
opcache.error_log=
opcache.log_verbosity_level=1
opcache.preferred_memory_model=
opcache.preload=
opcache.protect_memory=0
opcache.restrict_api=
opcache.mmap_base=0x20000000
opcache.file_cache="C:\Windows\Temp"
opcache.file_cache_only=0
opcache.file_cache_consistency_checks=1
opcache.file_cache_fallback=1
opcache.huge_code_pages=1
[wincache]
;extension=php_wincache.dll
wincache.fcenabled = 1
wincache.fcachesize = 1024M
wincache.maxfilesize = 2M
wincache.filecount 16384
wincache.ocenabled = 1
wincache.ocachesize = 1024M
wincache.chkinterval = 300
wincache.ttlmax 7200
wincache.ignorelist = "index.php|wp-login.php|user.php"
wincache.ucenabled = 1
wincache.fcndetect = 1
wincache.fcenabledfilter = NULL
wincache.enablecli = 1
wincache.ucachesize = 128
wincache.scachesize = 128
[igbinary]
;extension=php_igbinary.dll
igbinary.compact_strings=On
;session.serialize_handler=igbinary
;apc.serializer=igbinary
[redis]
;extension=php_redis.dll
;session.save_handler = redis
;session.save_path = "tcp://127.0.0.1:6379"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65[PHP_EXIF]
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=12000
opcache.max_wasted_percentage=60
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.revalidate_path=0
opcache.save_comments=1
opcache.fast_shutdown=0
opcache.enable_file_override=0
opcache.optimization_level=0xffffffff
opcache.inherited_hack=1
opcache.dups_fix=0
opcache.blacklist_filename=
opcache.max_file_size=0
opcache.consistency_checks=0
opcache.force_restart_timeout=180
opcache.error_log=
opcache.log_verbosity_level=1
opcache.preferred_memory_model=
opcache.preload=
opcache.protect_memory=0
opcache.restrict_api=
opcache.mmap_base=0x20000000
opcache.file_cache="C:\Windows\Temp"
opcache.file_cache_only=0
opcache.file_cache_consistency_checks=1
opcache.file_cache_fallback=1
opcache.huge_code_pages=1
[wincache]
;extension=php_wincache.dll
wincache.fcenabled=1
wincache.fcachesize=1024M
wincache.maxfilesize=2M
wincache.filecount16384
wincache.ocenabled=1
wincache.ocachesize=1024M
wincache.chkinterval=300
wincache.ttlmax7200
wincache.ignorelist="index.php|wp-login.php|user.php"
wincache.ucenabled=1
wincache.fcndetect=1
wincache.fcenabledfilter=NULL
wincache.enablecli=1
wincache.ucachesize=128
wincache.scachesize=128
[igbinary]
;extension=php_igbinary.dll
igbinary.compact_strings=On
;session.serialize_handler=igbinary
;apc.serializer=igbinary
[redis]
;extension=php_redis.dll
;session.save_handler=redis
;session.save_path="tcp://127.0.0.1:6379"
iis处理程序映射
添加模块映射
*.php
FastCgiModule
"C:\Program Files\php\php7.4.x_x64\php-cgi.exe"
PHP_via_FastCGI
1
2
3
4*.php
FastCgiModule
"C:\ProgramFiles\php\php7.4.x_x64\php-cgi.exe"
PHP_via_FastCGI
环境变量的添加
C:\Program Files\php\php7.4.x_x64\;C:\Program Files\php\php7.3.x_x64\;C:\Program Files (x86)\PHP5.3.x_x86\;
1C:\ProgramFiles\php\php7.4.x_x64\;C:\ProgramFiles\php\php7.3.x_x64\;C:\ProgramFiles(x86)\PHP5.3.x_x86\;
web.config多php版本配置(只需要头部 里面排除php版本的一段就可以)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42<?xmlversion ="1.0"encoding="UTF-8"?>
//2020.01.23
php7.4.2版本下午刚刚发布,正好wincache的7.4.1版本也在下午发布,刚才测试了会,感觉正常,有了这个扩展,速度进一步提升。本来还想写点什么,但明天就过年了,还是不写了。
php官方下载地址: