centos6 编译安装php 5.6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6 编译安装php 5.6相关的知识,希望对你有一定的参考价值。

1、安装编译需要的库
yum -y install make gcc libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel  krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel  gmp-devel pspell-devel curl-devel


2、因为部分包官方源没有,所以添加 epel 源进行安装(选择系统对应版本下载)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum install libmcrypt-devel libmcrypt mhash mcrypt -y           


3、还有一个yum安装不了的,用源码安装吧
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install


4、接下来正式安装php(解压,编译,安装,拷贝配置文件,创建用户)
tar zxvf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --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 --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 --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
make && make install
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
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
useradd -s /sbin/nologin -M www(因为在编译php是指定了用户和组,所以要创建)
/etc/init.d/php-fpm start

5、修改nginx配置文件使之支持php
vim /usr/local/nginx/conf/nginx.conf(找到自己环境的nginx配置文件)

找到下面的这段,把其

#location ~ \.php$ {

#    root           html;

#    fastcgi_pass   127.0.0.1:9000;

#    fastcgi_index  index.php;

#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

#    include        fastcgi_params;

#}

修改为

location ~ \.php$ {

    fastcgi_pass   127.0.0.1:9000;

    fastcgi_index  index.php;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    include        fastcgi_params;

}

修改完配置之后

测试一下是否有错:/usr/local/nginx/sbin/nginx -t

平滑重启:/usr/local/nginx/sbin/nginx -s reload

以上是关于centos6 编译安装php 5.6的主要内容,如果未能解决你的问题,请参考以下文章

php编译安装php-5.6

PHP 5.6编译安装

Linux之php编译安装5.6

CentOS 6.5系统安装编译安装MySQL 5.6详细过程

LAMP——httpd 2.4.20 + mysql-5.6.26 + php-5.6.22编译安装过程

linux centos6.5 php5.6 安装PHPUnit 5.2.9 (转)