mysql 编译安装php5.6_Centos7.6编译安装php5.6

当前系统环境Centos7.6,php版本5.6.39

1、安装epel源,安装所需依赖

yum install epel-release

yum install gcc gcc-c++ libxml2-devel libxml2 openssl openssl-devel curl curl-devel libjpeg-devel libpng-devel freetype-devel icu libicu libicu-devel libmcrypt libmcrypt-devel libxslt libxslt-devel

1

2

yuminstallepel-release

yuminstallgccgcc-c++libxml2-devellibxml2opensslopenssl-develcurlcurl-devellibjpeg-devellibpng-develfreetype-develiculibiculibicu-devellibmcryptlibmcrypt-devellibxsltlibxslt-devel

2、下载php5.6

cd /usr/local/src

wget http://cn2.php.net/distributions/php-5.6.39.tar.gz

1

2

cd/usr/local/src

wgethttp://cn2.php.net/distributions/php-5.6.39.tar.gz

3、解压编译安装

useradd -s /bin/false -M www

tar xf php-5.6.39.tar.gz

cd php-5.6.39

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-intl --with-xsl

make

make install

1

2

3

4

5

6

useradd-s/bin/false-Mwww

tarxfphp-5.6.39.tar.gz

cdphp-5.6.39

./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-config-file-scan-dir=/usr/local/php/conf.d--enable-fpm--with-fpm-user=www--with-fpm-group=www--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-iconv-dir--with-freetype-dir=/usr/local/freetype--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--enable-mbregex--enable-mbstring--with-mcrypt--enable-ftp--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--with-gettext--disable-fileinfo--enable-opcache--enable-intl--with-xsl

make

makeinstall

4、配置php.ini和php-fpm.conf

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

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

1

2

cpphp.ini-production/usr/local/php/etc/php.ini

cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

编辑php.ini设置以下参数

vi /usr/local/php/etc/php.ini

1

vi/usr/local/php/etc/php.ini

cgi.fix_pathinfo=0

date.timezone = PRC

short_open_tag = On

1

2

3

cgi.fix_pathinfo=0

date.timezone=PRC

short_open_tag=On

编辑php-fpm.conf设置以下参数

vi /usr/local/php/etc/php-fpm.conf

1

vi/usr/local/php/etc/php-fpm.conf

listen.owner = www

listen.group = www

listen = /var/run/php-fpm/php-fpm.sock

1

2

3

listen.owner=www

listen.group=www

listen=/var/run/php-fpm/php-fpm.sock

创建socket目录

mkdir /var/run/php-fpm/

1

mkdir/var/run/php-fpm/

注意:php.ini和php-fpm根据使用情况自行调整,这里只是一个简单的示例

5、配置php-fpm服务并设置开机启动

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

1

2

3

4

cpsapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

chmod+x/etc/init.d/php-fpm

chkconfig--addphp-fpm

chkconfigphp-fpmon

6、配置环境变量

echo 'export PATH=$PATH:/usr/local/php/bin' >> /etc/profile

echo 'export PATH=$PATH:/usr/local/php/bin' >> ~/.bashrc

source /etc/profile

1

2

3

echo'export PATH=$PATH:/usr/local/php/bin'>>/etc/profile

echo'export PATH=$PATH:/usr/local/php/bin'>>~/.bashrc

source/etc/profile

7、启动php服务

/etc/init.d/php-fpm start

8、在nginx上配置php

location ~ [^/]\.php(/|$) {

try_files $uri =404;

include fastcgi.conf;

fastcgi_index index.php;

fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

}

1

2

3

4

5

6

location~[^/]\.php(/|$){

try_files$uri=404;

includefastcgi.conf;

fastcgi_indexindex.php;

fastcgi_passunix:/var/run/php-fpm/php-fpm.sock;

}

9、验证

最后写个phpinfo到web下,验证php是否正常即可

4a18ecff2246c7a12593d607469add98.gif

~微信打赏~

分享到:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值