Centos7安装Nginx

(..•˘_˘•..) 版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创! (..•˘_˘•..)某些网站的小编真的是眼瞎! 转载注明出处!求求你了!

下载nginx包

wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装nginx

yum install nginx -y

启动并自启

systemctl start nginx
systemctl enable nginx

php配置

yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install mod_php72w php72w-opcache php72w-fpm php72w-opcache php72w-mysql php72w-xml php72w-xmlrpc -y
yum install yum-plugin-replace

启动并自启

systemctl start php-fpm
systemctl enable php-fpm

Nginx配置

vim /etc/nginx/conf.d/default.conf

配置文件

server {
    listen       80;
    server_name  localhost;

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

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    #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           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$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;
    #}
        location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
}

重启Nginx

systemctl restart nginx

善用日志文件排错

cat /var/log/nginx/error.log

防火墙端口开启不再赘述

原文链接:https://www.idaobin.com/archives/1953.html

既然都复制粘贴转载了,就不能打赏一点…ヘ( ̄ω ̄ヘ)

支付宝 ——————- 微信
图片加载中图片加载中

发表评论

电子邮件地址不会被公开。 必填项已用*标注

43 − 34 =