gpt4 book ai didi

NGINX 更改配置位置

转载 作者:行者123 更新时间:2023-12-04 02:52:18 40 4
gpt4 key购买 nike

我正在努力在服务器上配置 NGINX,并且我已经能够将所有文件放入 /usr/local/nginx/html/ .我还创建了一个 nginx.conf文件在 /usr/local/nginx/conf .它包含的所有内容是:

server {
root /usr/local/nginx/html;
index index.html index.html;
}
我一直在用 /usr/local/因为这是我唯一有权写入的内容。当我去查看站点时,我仍然得到 Nginx index.html带有消息的页面:

This is the default index.html page that is distributed with nginx on EPEL. It is located in /usr/share/nginx/html.

You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /etc/nginx/nginx.conf.


我想我的问题是,如何配置我的 nginx.conf文件,以便它使用该 conf 文件并从站点文件的更正位置提取?

最佳答案

无论您是在 shell 中启动 nginx 还是使用守护程序服务(它只是命令行 api 的包装器),答案都在 the command line API 中。 .

如您所知,nginx 查找配置文件的默认位置是/etc/nginx/nginx.conf,但您可以使用 -c 传入任意路径。旗帜。例如。:

$ nginx -c /usr/local/nginx/conf


其他一些注意事项:
  • 我怀疑是否有充分的理由在您的服务器块中重复“index.html”。
  • 我会将您的配置文件命名为“nginx.conf”(您目前表示它只是命名为“conf”)。这是标准。
  • 熟悉另一个命令行标志 -t ,它只是检查以确保您的配置文件有效。运行 nginx -t每次修改您的配置文件后,它都会吐出任何语法错误。要在更改后重新加载配置,请使用 nginx -s reload .
  • 关于NGINX 更改配置位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26351608/

    40 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com