Commit 648b2c3 1 parent f89eb52 commit 648b2c3 Copy full SHA for 648b2c3
File tree 3 files changed +39
-5
lines changed
3 files changed +39
-5
lines changed Original file line number Diff line number Diff line change 1
- ## 升级 PHP 版本 步骤
1
+ # 升级 PHP 版本 步骤
2
2
3
3
> 1、修改 sapi/PHP-VERSION.conf 文件里版本号即可
4
- > 2、执行同步源码脚本, 拉取 PHP 官方源码 到本项目
4
+
5
+ > 2、修改 sync-source-code.php 文件里 PHP 源码包的 sha256sum 配置
6
+
7
+ > 3、执行同步源码脚本, 拉取 PHP 官方源码 到本项目
8
+
9
+ > 4、sapi/cli/ 代码的升级,需要手动确认
5
10
6
11
``` shell
7
12
Original file line number Diff line number Diff line change 3
3
$ poject_dir = realpath (__DIR__ . '/../../ ' );
4
4
$ php_version_tag = trim (file_get_contents ($ poject_dir . '/sapi/PHP-VERSION.conf ' ));
5
5
$ php_source_folder = $ poject_dir . "/var/php- {$ php_version_tag }" ;
6
- $ php_archive_file = $ poject_dir . "/pool/php/php- {$ php_version_tag }.tar.gz " ;
6
+ $ php_archive_file = $ poject_dir . "/pool/php-tar/php- {$ php_version_tag }.tar.gz " ;
7
+ $ php_archive_file_sha256sum = '41c9e703caaf73ba6c77ee641709a3a5378a5dcb7bcc1fd1997f6e156a84abd4 ' ;
7
8
$ download_dir = dirname ($ php_archive_file );
9
+ $ download_php_counter = 0 ;
8
10
11
+ DOWNLOAD_PHP :
9
12
# 下载 PHP 源码
10
13
$ download_cmd = "curl -fSL https://github.com/php/php-src/archive/refs/tags/php- {$ php_version_tag }.tar.gz -o {$ php_archive_file }" ;
11
14
echo $ download_cmd . PHP_EOL ;
12
15
if (!file_exists ($ php_archive_file )) {
13
16
`test -d {$ download_dir } || mkdir -p {$ download_dir }`;
17
+ $ download_php_counter ++;
14
18
`{$ download_cmd }`;
15
19
}
16
20
21
+ $ hash = hash_file ('sha256 ' , $ php_archive_file );
22
+ echo "sha256sum: " . $ hash . PHP_EOL ;
23
+ if ($ hash !== $ php_archive_file_sha256sum ) {
24
+ if ($ download_php_counter > 3 ) {
25
+ throw new \Exception ('curl download php archive Exception! ' , 500 );
26
+ }
27
+ echo 'archive sha256sum mismatched , will re-download ' . PHP_EOL ;
28
+ unlink ($ php_archive_file );
29
+ goto DOWNLOAD_PHP ;
30
+ }
31
+
17
32
# 若不存在则解压 PHP 源码包
18
33
# tar -zxvf 文件名.tar.gz --strip-components=1 -C 指定解压目录
19
34
Original file line number Diff line number Diff line change 30
30
//测试同步
31
31
# 准备工作 测试目录
32
32
33
-
34
33
$ directories = array_intersect ($ scanned_directory_source , $ scanned_directory_destination );
35
34
36
35
`test -d {$ sync_dest_dir } && rm -rf {$ sync_dest_dir }`;
59
58
# 执行代码同步之前准备
60
59
$ SYNC_SOURCE_CODE_SHELL .= PHP_EOL . <<<EOF
61
60
SRC= {$ php_source_folder }
62
- cd {$ sync_dest_dir }
61
+ __PROJECT__= {$ project_dir }
62
+ __WORKDIR__= {$ sync_dest_dir }
63
+ cd \${WORKDIR}
63
64
EOF ;
64
65
65
66
# 准备 同步代码脚本
70
71
cp -rf $SRC/Zend/. ./Zend
71
72
72
73
# Extension
74
+ echo 'clean extension'
75
+ cd ${SRC}/ext/
76
+ EXTENSIONS=$(ls -d */)
77
+ cd ${__WORKDIR__}/
78
+ for EXT_NAME in $EXTENSIONS; do
79
+ EXT_NAME=$(echo "$EXT_NAME" | sed 's@.\{1\}$@@')
80
+ echo "EXTENSION_NAME: $EXT_NAME "
81
+ test -d ${__WORKDIR__}/ext/${EXT_NAME} && rm -rf ${__WORKDIR__}/ext/${EXT_NAME}
82
+ done
83
+
84
+ echo 'sync extensions '
85
+ cd ${__WORKDIR__}/
86
+
73
87
cp -rf $SRC/ext/bcmath/. ./ext/bcmath
74
88
cp -rf $SRC/ext/bz2/. ./ext/bz2
75
89
cp -rf $SRC/ext/calendar/. ./ext/calendar
You can’t perform that action at this time.
0 commit comments