欢迎来到代码驿站!

Linux

当前位置:首页 > 服务器 > Linux

centos6.6 下 安装 php7 + nginx环境的方法

时间:2020-11-26 21:44:01|栏目:Linux|点击:

本文实例讲述了centos6.6 下 安装 php7 + nginx环境的方法。分享给大家供大家参考,具体如下:

1、安装必要的依赖库

> yum -y install gd zlib libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel

2、下载php源码包

http://php.net/downloads.php

文件名为:php-7.0.4.tar.gz

3、解压源码包

> tar -zxvf php-7.0.4.tar.gz

4、进入目录,并configure

./configure --prefix=/data/nmp/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib \
--with-libxml-dir \
--with-mysqli=mysqlnd \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-mysqlnd \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--enable-pthreads \
--enable-maintainer-zts \
--enable-fileinfo

5、make && make install

> make && make install

6、配置文件

> cp php.ini-development /data/nmp/php/lib/php.ini
> cp /data/nmp/php/etc/php-fpm.conf.default /data/nmp/php/etc/php-fpm.conf
> cp /data/nmp/php/etc/php-fpm.d/www.conf.default /data/nmp/php/etc/php-fpm.d/www.conf
> cp -R ./sapi/fpm/php-fpm /data/nmp/php/etc/init.d/php-fpm

(*需要创建init.d目录)

7、启动

> /data/nmp/php/etc/init.d/php-fpm

8、nginx整合php

> vi /data/nmp/nginx/conf/nginx.conf

server {
  listen    80;
  server_name localhost;
 
  charset utf-8;
 
  #root网站的目录
  location / {
    root  /data/wwwroot;
    index index.html index.htm index.php;
  }
 
  location ~ \.php$ {
 
    #网站目录
    root      /data/wwwroot;
    #phpcgi端口,默认9000
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
 
    #document_root指向的就是网站目录
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include    fastcgi_params;
  }
}

9、重新加载nginx

> /data/nmp/nginx/sbin/nginx -s reload

希望本文所述对大家centos环境配置有所帮助。

上一篇:centos下yum搭建安装linux+apache+mysql+php环境的方法

栏    目:Linux

下一篇:Linux设置虚拟内存的教学与实战教程

本文标题:centos6.6 下 安装 php7 + nginx环境的方法

本文地址:http://www.codeinn.net/misctech/26337.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有