麒麟系统安装nginx-php7.2.32
安装依赖
1 | yum install libxml2 xz-devel libxml2-devel libjpeg-turbo-devel libpng-devel libicu-devel libxslt-devel gcc g++ cmake freetype-devel |
安装 libiconv
1 | wget http://mirrors.linuxeye.com/oneinstack/src/libiconv-1.16.tar.gz |
安装 openssl
1 | wget http://mirrors.linuxeye.com/oneinstack/src/openssl-1.1.1g.tar.gz |
安装 curl
1 | wget http://mirrors.linuxeye.com/oneinstack/src/curl-7.71.1.tar.gz |
安装 freetype
1 | wget http://mirrors.linuxeye.com/oneinstack/src/freetype-2.10.1.tar.gz |
安装 argon2
1 | wget http://mirrors.linuxeye.com/oneinstack/src/argon2-20171227.tar.gz |
安装 libsodium
1 | wget http://mirrors.linuxeye.com/oneinstack/src/libsodium-1.0.18.tar.gz |
安装 mhash
1 | wget http://mirrors.linuxeye.com/oneinstack/src/mhash-0.9.9.9.tar.gz |
安装 php7.2.32
1 | wget http://mirrors.linuxeye.com/oneinstack/src/php-7.2.32.tar.gz |
- 如果是mips架构,修改
ext/pcre/pcrelib/sljit/sljitNativeMIPS_common.c
1
2
3
4
5
6
7
8
9
10
11
12SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
{
sljit_sw fir = 0; // 这里初始化变量
switch (feature_type) {
case SLJIT_HAS_FPU:
return SLJIT_IS_FPU_AVAILABLE;
//sljit_sw fir; // 这里注释掉
asm ("cfc1 %0, $0" : "=r"(fir));
return (fir >> 22) & 0x1;
编译php
1
2
3
4
5
6
7
8
9
10
11
12
13
14# 如果是mips架构, 增加 --host=mips64选项
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/etc/php.d \
--with-fpm-user=www --with-fpm-group=www --enable-fpm --enable-opcache --disable-fileinfo \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd --with-openssl=/usr/local/openssl \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --enable-soap --disable-debug
make -j 4 && echo $?
sudo make install && echo $? - 报错处理: 错误 undefined t_type
1 | echo "/usr/local/lib |
配置PATH
1 | export PATH=/usr/local/php/bin/:$PATH |
配置php.ini
1 | # 复制配置文件 |
开启opcache
1 | sudo cat > /usr/local/php/etc/php.d/02-opcache.ini << EOF |
新建服务
- sudo vim /lib/systemd/system/php-fpm.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[Unit]
Description=The PHP FastCGI Process Manager
Documentation=http://php.net/docs.php
After=network.target
[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
LimitNOFILE=1000000
LimitNPROC=1000000
LimitCORE=1000000
[Install]
WantedBy=multi-user.target新建fpm配置文件
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
sudo cat > /usr/local/php/etc/php-fpm.conf <<EOF
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = warning
emergency_restart_threshold = 30
emergency_restart_interval = 60s
process_control_timeout = 5s
daemonize = yes
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
[www]
listen = /dev/shm/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 12
pm.start_servers = 8
pm.min_spare_servers = 6
pm.max_spare_servers = 12
pm.max_requests = 2048
pm.process_idle_timeout = 10s
request_terminate_timeout = 120
request_slowlog_timeout = 0
pm.status_path = /php-fpm_status
slowlog = var/log/slow.log
rlimit_files = 51200
rlimit_core = 0
catch_workers_output = yes
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
EOF
按机器内存大小修改fpm配置文件
< 3000M
1
2
3
4
5 $Mem = $((`free -m | awk '/Mem:/{print $2}'`/3/20))
sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" /usr/local/php/etc/php-fpm.conf3000M - 4500M
1
2
3
4 sed -i "s@^pm.max_children.*@pm.max_children = 50@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" /usr/local/php/etc/php-fpm.conf4500M - 6500M
1
2
3
4 sed -i "s@^pm.max_children.*@pm.max_children = 60@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" /usr/local/php/etc/php-fpm.conf6500M - 8500M
1
2
3
4 sed -i "s@^pm.max_children.*@pm.max_children = 70@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" /usr/local/php/etc/php-fpm.conf8500以上
1
2
3
4
5
6
7
8
9
10 sed -i "s@^pm.max_children.*@pm.max_children = 80@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" /usr/local/php/etc/php-fpm.conf
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" /usr/local/php/etc/php-fpm.conf
##### 启动php-fpm
```bash
systemctl enable php-fpm
systemctl start php-fpm