PHP编译安装
Posted 一木浮生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP编译安装相关的知识,希望对你有一定的参考价值。
一、前言
(一)、概述
(二)、预处理
配置环境
OS:CentOS 7.5 64bit
php版本:7.2.8
hostname:php-1-1
ip:10.18.43.141
[[email protected]1-1 ~]# systemctl stop firewalld
[[email protected]-1-1 ~]# sed -ri ‘/^SELINUX=*/cSELINUX=disabled‘ /etc/selinux/config
[[email protected]-1-1 ~]# setenforce 0
[[email protected]-1-1 ~]# mkdir -p /date/php
二、安装
(一)、PHP编译
依赖环境库下载
[[email protected]1-1 ~]# 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 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libxslt libxslt-devel
源码包获取及编译
[[email protected]1-1 ~]# wget -P /data/php/ http://cn2.php.net/distributions/php-7.2.8.tar.bz2 [[email protected]1-1 ~]# cd /data/php/ [[email protected]-1-1 php]# tar xf php-7.2.8.tar.bz2
[[email protected] php]# cd php-7.2.8/
[[email protected] php-7.2.8]#./configure
--prefix=/usr/local/php
--with-curl
--with-freetype-dir
--with-gd
--with-ldap
--with-gettext
--with-iconv-dir
--with-jpeg-dir
--with-kerberos
--with-libdir=lib64
--with-libxml-dir
--with-mysqli
--with-openssl
--with-pcre-regex
--with-pdo-mysql
--with-pdo-sqlite
--with-pear
--with-png-dir
--with-xmlrpc
--with-xsl
--with-zlib
--enable-fpm
--enable-bcmath
--enable-libxml
--enable-inline-optimization
--enable-mbregex
--enable-mbstring
--enable-opcache
--enable-pcntl
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvsem
--enable-xml
--enable-zip
--with-fpm-group=nginx
--with-fpm-user=nginx
三、配置启动
(一)、基础配置
[[email protected]1-1 php-7.2.8]# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
[[email protected]-1-1 php-7.2.8]# cp /usr/local/php/etc/{php-fpm.conf.default,php-fpm.conf}
[[email protected]-1-1 php-7.2.8]# cp /usr/local/php/etc/php-fpm.d/www.conf{.default,}
[[email protected]-1-1 php-7.2.8]# cp php.ini-production /usr/local/php/lib/php.ini
(二)、参数配置
[[email protected]1-1 php-7.2.8]# sed -i ‘/date.timezone =/s/.*/date.timezone = PRC/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -n ‘869p‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache]/azend_extension=opcache.so‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/;opcache.enable=1/s/;//g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache.enable_cli=/s/.*/opcache.enable_cli=1/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# echo "vm.nr_hugepages = 200" >> /etc/sysctl.conf
[[email protected]-1-1 php-7.2.8]# sysctl -p
[[email protected]-1-1 php-7.2.8]# sed -i ‘/;opcache.huge_code_pages/s/;//g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache.memory_consumption=/s/.*/opcache.memory_consumption=512/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache.fast_shutdown=/s/.*/opcache.fast_shutdown=1/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache.validate_timestamps=/s/.*/opcache.validate_timestamps=1/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/opcache.revalidate_freq=/s/.*/opcache.revalidate_freq=2/g‘ /usr/local/php/lib/php.ini
[[email protected]-1-1 php-7.2.8]# sed -i ‘/listen = 127.0.0.1/s/=.*/= 0.0.0.0:9000/g‘ /usr/local/php/etc/php-fpm.d/www.conf
(三)、启动使用
[[email protected]1-1 php-7.2.8]# systemctl start php-fpm.service
[[email protected]-1-1 php-7.2.8]# systemctl enable php-fpm.service
以上是关于PHP编译安装的主要内容,如果未能解决你的问题,请参考以下文章