Linux CentOS 编译安装 php7.2

             

Linux CentOS 完全卸载 PHP

php 编译安装

1.添加用户

useradd -r -s /sbin/nologin php-fpm 

2.下载解压安装包

下载的 php-7.2.12.tar.gz

[root@bogon lib64]# tar zxvf php-7.2.12.tar.gz 
[root@bogon lib64]# cd /usr/local/lib64/php-7.2.12

3.安装依赖

[root@bogon php-7.2.12]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libicu-devel libxslt-devel 

4. configure生成 Makefile

[root@bogon php-7.2.12]# ./configure \
--prefix=/usr/local/php-7.2.2 \
--with-mhash \
--with-openssl \
--with-config-file-path=/usr/local/php-7.2.2/etc \
--disable-short-tags \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--enable-xml \
--with-libxml-dir \
--enable-bcmath \
--enable-calendar \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-zip \
--enable-mbregex \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--enable-ftp \
--with-curl \
--with-xsl \
--with-iconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--enable-sysvsem \
--enable-inline-optimization \
--with-xmlrpc \
--with-gettex

5.编译

[root@bogon php-7.2.12]# make

6.安装

[root@bogon php-7.2.12]# make install

7.php和php-fpm建立软链

[root@bogon php-7.2.12]# ln -s /usr/local/php-7.2.2/bin/php /usr/local/bin/
[root@bogon php-7.2.12]# ln -s /usr/local/php-7.2.2/sbin/php-fpm /usr/local/sbin/

8.复制配置文件到php目录

[root@bogon php-7.2.12]# cp ./php.ini-development ./php.ini-production /usr/local/php-7.2.2/etc/
[root@bogon php-7.2.12]# cp /usr/local/php-7.2.2/etc/php.ini-development /usr/local/php-7.2.2/etc/php.ini
[root@bogon php-7.2.12]# cp /usr/local/php-7.2.2/etc/php-fpm.conf.default /usr/local/php-7.2.2/etc/php-fpm.conf
[root@bogon php-7.2.12]# cp /usr/local/php-7.2.2/etc/php-fpm.d/www.conf.default /usr/local/php-7.2.2/etc/php-fpm.d/www.conf

9.建立配置文件软链

[root@bogon php-7.2.12]# ln -s /usr/local/php-7.2.2/etc/php.ini /usr/local/etc/
[root@bogon php-7.2.12]# ln -s /usr/local/php-7.2.2/etc/php-fpm.conf /usr/local/etc/
[root@bogon php-7.2.12]# ln -s /usr/local/php-7.2.2/etc/php-fpm.d/www.conf /usr/local/etc/

10.配置环境变量,加入全局命令

[root@bogon php-7.2.12]# vim /etc/profile 
#添加
PATH=$PATH:/usr/local/php-7.2.2/bin 
export PATH 
#保存退出 source 立即生效
[root@bogon php-7.2.12]# source /etc/profile

11.启动 php-fpm 服务

[root@bogon php-7.2.12]# /usr/local/sbin/php-fpm 

12.查看是否启动

[root@bogon php-7.2.12]# netstat -lnt | grep 9000
# 或者
ps -ef | grep php-fpm 

13.杀死 php-fpm

[root@bogon php-7.2.12]# pkill php-fpm


发表评论 请登录再评论
  •   文章分类
回到顶部