Centos7.6编译安装php7.2.3

已邀请:

1、安装依赖组件,创建用户

groupadd www
useradd -g www www
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip

2、下载php

mkdir -p  /data/software/php/  && cd /data/software/php/
wget http://cn2.php.net/distributions/php-7.2.3.tar.gz

3、解压安装包,进入到php源码目录

cd /data/software/php
tar -zxvf php-7.2.3.tar.gz
cd /data/software/php/php-7.2.3/

4、编译

./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php/conf --disable-rpath --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --with-onig --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-readline --with-libxml-dir --with-xsl --with-pear --enable-gd-jis-conv --enable-zip --enable-shmop --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-mbstring --enable-bcmath --with-ldap=shared

5、安装

make && makeinstall

6、确认版本

/usr/local/php/bin/php -v

7、初始化配置文件,添加服务

mkdir -p /usr/local/php/conf
cp php.ini-production /usr/local/php/conf/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
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service

8、设置开机启动

systemctl enable php-fpm.service



附,服务脚本参数解读

Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

要回复问题请先登录注册