centos6.9 PHP的编译安装并连接nginx

1.安装yum -y install libxml2-devel openssl-devel bzip2-devel libmcrypt-devel 解决php包的依赖关系,可能libmcrypt会报错,先执行yum  install epel-release,再重新安装一下就可以了。

centos6.9 PHP的编译安装并连接nginx

2.下载PHP安装包并且上传到服务器,解压,(或者可以用wget直接下载到服务器)。

centos6.9 PHP的编译安装并连接nginx

3.在PHP包的位置编译php:

./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

centos6.9 PHP的编译安装并连接nginx

4.make && make install

centos6.9 PHP的编译安装并连接nginx

5.复制相关配置文件到相关位置上:

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

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

6.加权限并设置开机启动php

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

7.开启php服务:

/usr/local/php/sbin/php-fpm或者  /etc/init.d/php-fpm start

centos6.9 PHP的编译安装并连接nginx

8.查看php是否启动成功:

netstat -lnt |grep 9000

centos6.9 PHP的编译安装并连接nginx

9.建一个存放nginx的网站根目录:

mkdir -p /tmp/www/zabbixserver.com

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

10.在nginx.cong配置文件中的http模块加上一条命令:

include /usr/local/nginx/conf/vhost/*.conf ;

centos6.9 PHP的编译安装并连接nginx

11.根据“ include /usr/local/nginx/conf/vhost/*.conf ”在相对应的位置添加文件

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

12.把相关配置贴进去:

server
{
listen 80;  #(不要与nginx.conf的端口冲突了)
server_name zabbixserver.com;
access_log /usr/local/nginx/logs/zabbixserver.com.access.log ;

index index.html index.htm index.php;
root /tmp/www/zabbixserver.com;

charset utf-8;

expires 2h;

location ~ .*\.(php)?$ {
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;

}
}

centos6.9 PHP的编译安装并连接nginx

13.测试是否成功

cd /usr/local/nginx/sbin

./nginx -t

centos6.9 PHP的编译安装并连接nginx

14.重启nginx服务

./nginx -s reload

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

centos6.9 PHP的编译安装并连接nginx

上一篇:未能正确加载“Microsoft.VisualStudio.Editor.Implementation.EditorPackage”


下一篇:Mysql 语句汇总(性能篇)