Loading... <div class="tip share">请注意,本文编写于 2229 天前,最后修改于 1517 天前,其中某些信息可能已经过时。</div> 安装依赖 ``` yum -y install gcc gcc-c++ glibc openldap-devel.i686 openldap-devel ``` 下载PHP安装包 ``` http://mirrors.cmig.host/software/php/php-7.2.11.tar.gz ``` 解压 ``` tar -zxvf php-7.2.11.tar.gz ``` 进入PHP源码目录 ``` cd php-7.2.11 ``` 预编译 ``` ./configure \ --prefix=/data/php/7.2.11/ \ --with-config-file-path=/data/php/7.2.11/etc/ \ --with-mysql-sock \ --with-mysqli \ --with-pdo-mysql \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-gd \ --with-zlib \ --with-libxml-dir \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --with-mhash \ --with-openssl \ --enable-zip \ --enable-soap \ --enable-sockets \ --enable-fpm \ --enable-ftp \ --with-ldap ``` 编译并安装 ``` make && make install ``` 新增配置文件,主要是修改php-fpm的运行用户,不允许使用root用户 `vim /data/php/7.2.11/etc/php-fpm.d/www.conf` ``` [www] user = cmig group = cmig listen = 127.0.0.1:9000 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 ``` 附:PHP-FPM的启停脚本 ```bash #!/bin/sh # chkconfig: - 95 15 # Author: AnAn # Website: blog.90.vc # description: php-fpm # DateTime: 2018-09-20 # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 phpfpm="/data/php/7.2.11/sbin/php-fpm" prog=$(basename ${phpfpm}) lockfile=/var/lock/subsys/phpfpm start() { [ -x ${phpfpm} ] || exit 5 echo -n $"Starting $prog: " daemon ${phpfpm} retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc ${phpfpm} -HUP RETVAL=$? echo } force_reload() { restart } configtest() { ${phpfpm} -t } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" exit 2 esac ``` 最后修改:2020 年 10 月 19 日 © 允许付费转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏