centos7编译安装php5.6

centos7编译安装php5.6

  • 安装PHP扩展依赖
  • 添加组和用户
  • 下载包
  • 安装
  • 配置文件
  • 设置php-fpm开机自动启动,将init.d.php-fpm放在启动里面
  • 查看php-fpm端口

安装PHP扩展依赖

yum -y install -y gcc gcc-c++ libxml2-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel bzip2-devel libmcrypt-devel freetype-devel libxml2-devel m4 autoconf

添加组和用户

添加组
groupadd www
#添加php-fpm用户
useradd -g www www

下载包

php-5.6.30.tar.gz下载: https://download.csdn.net/download/gusijin/11329004

tar zxvf php-5.6.30.tar.gz
cd php-5.6.30/

安装

./configure --prefix=/usr/local/webservice/php56
–with-config-file-path=/usr/local/webservice/php56/etc
–enable-inline-optimization --disable-debug
–disable-rpath --enable-shared --enable-opcache
–enable-fpm --with-fpm-user=www
–with-fpm-group=www
–with-mysql=mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–with-gettext
–enable-mbstring
–with-iconv-dir
–with-freetype-dir
–with-jpeg-dir
–with-png-dir
–with-mcrypt
–with-mhash
–with-openssl
–with-gd
–enable-bcmath
–enable-soap
–with-libxml-dir
–enable-pcntl
–enable-shmop
–enable-sysvmsg
–enable-sysvsem
–enable-sysvshm
–enable-sockets
–with-curl --with-zlib
–enable-zip
–with-bz2
–with-readline

make编译
make && make install

配置文件

cp php.ini-production /usr/local/webservice/php56/etc/php.ini

#php-fpm 服务
cp /usr/local/webservice/php56/etc/php-fpm.conf.default /usr/local/webservice/php56/etc/php-fpm.conf

将php和php-fpm软链到/usr/bin
ln -s /usr/local/webservice/php56/bin/php /usr/bin/php
ln -s /usr/local/webservice/php56/sbin/php-fpm /usr/sbin/php-fpm

如果要多版本PHP共存,可以在软链时起个自己好记的别名,比如php56、php73,建议至少保留一个版本的默认名字叫php

设置php-fpm开机自动启动,将init.d.php-fpm放在启动里面

cp /home/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

#php-fpm进程管理器的开关重启
/etc/init.d/php-fpm start|stop|restart

chkconfig php-fpm on
systemctl start php-fpm

设置php为全局命令:
使用php -v确认

netstat -an |grep 9000

查看php-fpm端口

vim /usr/local/webservice/php5.6/etc/php-fpm.conf
listen = 127.0.0.1:9000

php --ini
查看路径

你可能感兴趣的:(php,centos)