CentOS7使用tar.gz方法安装php7.2.8

时间:2024-01-26 15:03:26

软件:VMware

系统版本:CentOS7

 

1.检查系统里是否有安装的PHP包,如果有的话先删除

[root@localhost ~]# yum list installed | grep php
[root@localhost ~]# yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64

 

2.安装开发工具包

[root@localhost ~]# yum groups mark install 'Development Tools'
[root@localhost ~]# yum -y install wget bzip2 bzip2-devel gcc gcc-c++

 

3.安装依赖包

[root@localhost ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel  libpcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php72w-mysqlnd

 

4..下载php

[root@localhost ~]# cd /usr/src/
[root@localhost src]#wget http://cn.php.net/distributions/php-7.2.8.tar.xz

 

5.编译安装php

[root@localhost src]# tar xf php-7.2.8.tar.xz
[root@localhost src]# cd php-7.2.8
[root@localhost php-7.2.8]# ./configure --prefix=/usr/local/php7 \ > --with-config-file-path=/etc \ > --enable-fpm \ > --enable-inline-optimization \ > --disable-debug \ > --disable-rpath \ > --enable-shared \ > --enable-soap \ > --with-openssl \ > --enable-bcmath \ > --with-iconv \ > --with-bz2 \ > --enable-calendar \ > --with-curl \ > --enable-exif \ > --enable-ftp \ > --with-gd \ > --with-jpeg-dir \ > --with-png-dir \ > --with-zlib-dir \ > --with-freetype-dir \ > --with-gettext \ > --enable-json \ > --enable-mbstring \ > --enable-pdo \ > --with-mysqli=mysqlnd \ > --with-pdo-mysql=mysqlnd \ > --with-readline \ > --enable-shmop \ > --enable-simplexml \ > --enable-sockets \ > --enable-zip \ > --enable-mysqlnd-compression-support \ > --with-pear \ > --enable-pcntl \ > --enable-posix  
[root@localhost php-7.2.8]# make && make instal

6.安装后配置

[root@localhos php-7.2.8]#  echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhos php-7.2.8]# . /etc/profile.d/php7.sh
[root@localhos php-7.2.8]# php -v

 

 

 

 

7.配置php-fpm

[root@localhos php-7.2.8]# cp php.ini-production /etc/php.ini
[root@localhos php-7.2.8]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhos php-7.2.8]# chmod +x /etc/rc.d/init.d/php-fpm
[root@localhos php-7.2.8]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@localhos php-7.2.8]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
[root@localhos php-7.2.8]# vim /usr/local/php7/etc/php-fpm.conf
[root@localhos php-7.2.8]# tail -4 /usr/local/php7/etc/php-fpm.conf

 

 

 

8.启动

[root@localhos php-7.2.8]# service php-fpm start

 

 

 

 

参考文档:https://blog.csdn.net/weixin_44437026/article/details/88066510