整理一下PHP7编译安装脚本和编译参数说明

整理中

./configure \
--prefix=/www/server/php \
--with-config-file-path=/www/server/php/etc \
--with-config-file-scan-dir=/www/server/php/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir\
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-pcntl \
--enable-ftp \
--with-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--without-libzip \
--enable-soap \
--with-gettext \
--enable-opcache \
--with-xsl \

php编译安装脚本

# php_install.sh

#!/bin/bash

PHP_VER='php-7.3.6'

cd ~
if [ ! -f ${PHP_VER}.tar.gz ];then
    wget https://www.php.net/distributions/${PHP_VER}.tar.gz
fi
tar -xf ${PHP_VER}.tar.gz
cd ${PHP_VER}


./configure \
--prefix=/www/server/php \
--with-config-file-path=/www/server/php/etc \
--with-config-file-scan-dir=/www/server/php/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir\
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-pcntl \
--enable-ftp \
--with-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--without-libzip \
--enable-soap \
--with-gettext \
--enable-opcache \
--with-xsl \

make && make install

ln -sf /www/server/php/bin/php /usr/bin/php
ln -sf /www/server/php/bin/phpize /usr/bin/phpize
ln -sf /www/server/php/bin/pear /usr/bin/pear
ln -sf /www/server/php/bin/pecl /usr/bin/pecl

mkdir -p /www/server/php/{etc,conf.d}
\cp php.ini-production /www/server/php/etc/php.ini


# php extensions
sed -i 's/post_max_size =.*/post_max_size = 50M/g' /www/server/php/etc/php.ini
sed -i 's/upload_max_filesize =.*/upload_max_filesize = 50M/g' /www/server/php/etc/php.ini
sed -i 's/;date.timezone =.*/date.timezone = PRC/g' /www/server/php/etc/php.ini
sed -i 's/short_open_tag =.*/short_open_tag = On/g' /www/server/php/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g' /www/server/php/etc/php.ini
sed -i 's/max_execution_time =.*/max_execution_time = 300/g' /www/server/php/etc/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /www/server/php/etc/php.ini

pear config-set php_ini /www/server/php/etc/php.ini
pecl config-set php_ini /www/server/php/etc/php.ini

cat >/www/server/php/etc/php-fpm.conf<<EOF
[global]
pid = /www/server/php/var/run/php-fpm.pid
error_log = /www/server/php/var/log/php-fpm.log
log_level = notice

[www]
listen = /tmp/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 = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
EOF

\cp /root/${PHP_VER}/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm