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;
}
修改完配置之后
原文链接:https://www.f2er.com/centos/378683.html