centos7+ 安装 php7.2

Posted IT老司机

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7+ 安装 php7.2相关的知识,希望对你有一定的参考价值。

yum install epel-release -y
yum update
安装依赖

yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

 

创建用户和组,并下载php安装包解压

 

cd /home/download
groupadd www
useradd -g www www
wget http://am1.php.net/distributions/php-7.2.1.tar.gz
tar xvf php-7.2.1.tar.gz
cd php-7.2.1

 

设置变量并开始源码编译:

 

cp -frp /usr/lib64/libldap* /usr/lib/

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --with-libmbfl --enable-ftp --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm

 

若无报错执行下一步安装,如果编译过程中出现错误,根据报错安装依赖包,通常不会出现这种问题。

注意:–enable-gd-jis-conv  此参数会导致Zabbix中文字符乱码,建议取消。

 

开始安装:

make -j 4 && make install

完成安装后配置php.ini文件:

cp php.ini-development /usr/local/php/etc/php.ini
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

 

创建system系统单元文件php-fpm启动脚本:

vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/usr/local/php/var/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

[Install]
WantedBy=multi-user.target

启动php-fpm服务并加入开机自启动:

systemctl enable php-fpm.service
systemctl restart php-fpm.service

 





以上是关于centos7+ 安装 php7.2的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7下PHP7.2安装redis扩展

CentOS7源码编译安装PHP7.2

CentOS7源码编译安装PHP7.2

Centos7 源码安装 PHP7.2

Centos7 编译安装PHP7.2

centos7.2 64位安装php7.2.12