`# 安装依赖包 yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \ libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel \ openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers `# 下载源码包 wget -c http://mirrors.sohu.com/php/php-7.2.13.tar.gz `# 解压 tar -xzvf php-7.2.13.tar.gz cd php-7.2.13 `# 预编译 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php \ --enable-mbstring --with-openssl --enable-ftp --with-gd --with-jpeg-dir=/usr \ --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --with-pear --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr \ --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib \ --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl `# 编译并安装 make && make install `# 拷贝配置文件和启动脚本 cp php.ini-development /usr/local/php/etc/php-fpm.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /root/php-7.2.25/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod o+x /etc/init.d/php-fpm `# 将php服务加入systemctl `#(1)自定义添加启动服务文件 vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/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 ExecStop=/bin/kill -SIGINT $MAINPID [Install] WantedBy=multi-user.target `#(2)添加环境变量 export PATH="$PATH:/usr/local/php/sbin" `#(3)在php.ini解析文件中加入 vim /usr/local/php/etc/php.ini zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/opcache.so
来源:https://www.cnblogs.com/IMSCZ/p/11997206.html