CentOS 7配置LNMP开发环境及配置文件管理详解

2019-10-13 10:05:54王冬梅

 yum --enablerepo=remi-php56 install php 

安装php-fpm

 yum --enablerepo=remi-php56 install php-fpm 

开启php-fpm

 systemctl start php-fpm 

安装并配置Nginx

导入gpg校验文件

 rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi 

下载源安装文件(配置Nginx安装源)。可从http://nginx.org/packages/centos/网站下载安装源。(注意:如果文章时间久,就可能需要去重新找新的下载链接。)

 wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm 

本地安装

 rpm -Uvh nginx-1.10.0-1.el7.ngx.x86_64.rpm 

安装Nginx

 yum install nginx 

开启Nginx

 systemctl start nginx 

Nginx主机配置(设置php-fpm)

编辑/etc/nginx/conf.d/default.conf配置文件,并重启。

 server {
  listen    80;
  server_name localhost;

  #charset koi8-r;
  #access_log /var/log/nginx/log/host.access.log main;

  root  /usr/share/nginx/html;
  index index.html index.htm index.php;

  #error_page 404       /404.html;

  # redirect server error pages to the static page /50x.html
  #
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  /usr/share/nginx/html;
  }

  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  #
  #location ~ .php$ {
  #  proxy_pass  http://127.0.0.1;
  #}

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ .php$ {
    root      html;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
    include    fastcgi_params;
  }

  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /.ht {
  #  deny all;
  #}
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。