CentOs 7.2 安裝PHP7.2 編譯安裝
阿新 • • 發佈:2018-11-13
安裝擴充套件包並更新系統核心
[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# yum update
YUM安裝PHP依賴元件(包含Nginx依賴):
[[email protected] ~]# yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libxslt-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib m4 autoconf gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel wget net-tools zip
下載php原始碼安裝包:
wget http://cn2.php.net/get/php-7.2.12.tar.gz/from/this/mirror
mv mirror php-7.2.12.tar.gz
編譯安裝配置PHP
編譯
[[email protected] php-7.2.12]# ./configure --prefix=/opt/php/php-7.2.12 \ --with-config-file-path=/opt/php/php-7.2.12/etc \ --with-curl \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-openssl \ --with-pcre-regex \ --with-pdo-sqlite \ --with-pear \ --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 \ --enable-static \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --disable-debug \ --disable-fileinfo \ --enable-maintainer-z
安裝:
[[email protected] php-7.2.12-src]# make clean && make -j 4 && make install
配置php.ini
[[email protected] etc]# pwd
/opt/php/php7.2/etc
[[email protected] etc]# find / -name php.ini-production
/opt/php/php7.2-src/php.ini-production
[[email protected] etc]# cp /opt/php/php7.2-src/php.ini-production php.ini
[ [email protected] etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d php.ini
[[email protected] etc]#
配置php-fpm:
[[email protected] etc]# pwd
/opt/php/php7.2/etc
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# ll
total 24
-rw-r--r-- 1 root root 1240 Apr 3 10:56 pear.conf
-rw-r--r-- 1 root root 4468 Apr 3 11:17 php-fpm.conf
-rw-r--r-- 1 root root 4468 Apr 3 10:55 php-fpm.conf.default
drwxr-xr-x 2 root root 4096 Apr 3 10:55 php-fpm.d
[[email protected] etc]#
[[email protected] php-fpm.d]# pwd
/opt/php/php7.2/etc/php-fpm.d
[[email protected] php-fpm.d]# cp www.conf.default www.conf
[[email protected] php-fpm.d]# ls
www.conf www.conf.default
[[email protected] php-fpm.d]#
[[email protected] php-fpm.d]# pwd
/opt/php/php7.2/etc/php-fpm.d
[[email protected] php-fpm.d]# find / -name php-fpm
/opt/php/php7.2-src/sapi/fpm/php-fpm
/opt/php/php7.2/sbin/php-fpm
/var/log/php-fpm
/run/php-fpm
[[email protected] php-fpm.d]# cp /opt/php/php7.2-src/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-fpm.d]# chmod +x /etc/init.d/php-fpm //新增許可權
啟動PHP
[[email protected] init.d]# pwd
/etc/init.d
[[email protected] init.d]# ./php-fpm start
Starting php-fpm done
[[email protected] init.d]# ps -ef | grep php-fpm
root 10402 1 0 11:33 ? 00:00:00 php-fpm: master process (/opt/php/php7.2/etc/php-fpm.conf)
nobody 10403 10402 0 11:33 ? 00:00:00 php-fpm: pool www
nobody 10404 10402 0 11:33 ? 00:00:00 php-fpm: pool www
root 10406 8032 0 11:33 pts/1 00:00:00 grep --color=auto php-fpm