目 录CONTENT

文章目录

centos7.9安装nginx

路口、下车
2025-07-14 / 0 评论 / 0 点赞 / 19 阅读 / 0 字
温馨提示:
本文最后更新于2025-08-14,若内容或图片失效,请留言反馈。 部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

运行环境

centos7.9

安装

下载Nginx

yum install nginx

Nginx的默认安装目录:

cd /etc/nginx

编辑Nginx配置文件

vi /etc/nginx/nginx.conf
```shell
启动ng
```shell
//启动ng
service nginx start

其他命令参数

systemctl daemon-reload #生效配置文件重载
systemctl enable nginx.service #设置开机启动
systemctl list-unit-files |grep nginx #查看nginx应用开机状态
systemctl start nginx.service #查看nginx应用启动状态
systemctl status nginx.service

基本配置

以代理到php为例


    server {
        listen       80;
        server_name  127.0.0.1;
        root         /var/www/html;
        index index.php index.html;
        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
        location ~ \.php$ {
            root           /var/www/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        location ~ /\.ht {
            deny  all;
        }
    }
0

评论区