PHP 7.2.10 编译安装
准备环境1.CentOS 系统
# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
2.防火墙
# systemctl stop firewalld
# systemctl disable firewalld
# cat /etc/sysconfig/selinux
SELINUX=disabled
# setenforce 0
# getenforce 0
Permissive
3.YUM,EPEl源
本地YUM源可以,或者选择其他外部源
# yum -y install epel-release
4.php依赖包
# yum -y install gcc gcc-c++ libmcrypt-devel mcrypt mhash gd-devel ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel openssl-deve python-devel zlib-devel freetype libxslt* bison autoconf re2c
5.php安装包
# wget http://cn2.php.net/distributions/php-7.2.10.tar.gz
# tar xvf php-7.2.10.tar.gz
# cd php-7.2.10/
# ./configure \
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--bindir=/usr/local/php/bin \
--sbindir=/usr/local/php/sbin \
--includedir=/usr/local/php/include \
--libdir=/usr/local/php/lib/php \
--mandir=/usr/local/php/php/man \
--with-config-file-path=/usr/local/php/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mhash \
--with-openssl \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-pcntl \
--enable-calendar \
--enable-exif \
--enable-sockets \
--with-xmlrpc \
--with-libxml-dir \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-bz2 \
--enable-opcache \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--without-gdbm \
--enable-fast-install \
--disable-fileinfo
# make
······
Build complete.
Don't forget to run 'make test'.
# make install
······
/root/php-7.2.10/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
# /usr/local/php/bin/php -v//版本验证
PHP 7.2.10 (cli) (built: Oct9 2018 09:59:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
6.编译PHP的选项说明
http://i2.运维网.com/images/blog/201810/09/7e1f0b6123fade06e694d60b2917f2e1.png
7.PHP安装后的配置
php.ini文件
# useradd nginx
#cp -a php.ini-production /usr/local/php/etc/php.ini
#cp -a php.ini-production /usr/local/php/etc/php.ini
#vim /usr/local/php/etc/php.ini
date.timezone = Asia/shanghai #指定时区为上海
expose_php = Off #禁止显示PHP版本
short_open_tag = ON #支持PHP短标签
opcache.enable=1 #PHP支持opcode缓存
opcache.enable_cli=0
zend_extension=opcache.so #在最后一行添加,开启opcode缓存功能
8.配置php-fpm和www.conf
#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod +x /etc/rc.d/init.d/php-fpm
#chkconfig --add php-fpm
9.环境变量
#cat /etc/profile
PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/
# source /etc/profile
10.启动 php-fpm
# systemctl start php-fpm
#ss -ant|grep 9000
LISTEN 0 128 127.0.0.1:9000 *:*
11.创建测试页
# yum -y install nginx
# vim /etc/nginx/nginx.conf
#把下面一段插入到server标签内
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#vim /usr/share/nginx/html/index.php
#创建php测试网页
# systemctl start nginx
12.测试
http://i2.运维网.com/images/blog/201810/09/2da20391a02a859ed1e67c6c7631ab18.png
http://i2.运维网.com/images/blog/201810/09/25c04266fda0dfbe53ac6baa4e1c2110.png
页:
[1]