php - 在centos 7中更改nginx根目录

标签 php nginx centos

如何在 centos 7 中更改 nginx 根目录?
我创建 default.conf在‍/etc/nginx/conf.d目录并放置以下代码

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /var/www/test;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
但是当用 service nginx start 启动 nginx 时返回此错误

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.


已编辑
的输出systemctl 状态 nginx.service

nginx.service - The nginx HTTP and reverse proxy server

Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)

Active: failed (Result: exit-code) since Sun 2019-07-07 19:21:49 IRDT; 11min ago

Process: 9976 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)

Process: 10101 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)

Process: 10099 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Main PID: 9978 (code=exited, status=0/SUCCESS)

最佳答案

nginx -t测试你的配置
如果错误是由多个服务器名称引起的,
尝试删除此default_server从你的配置

关于php - 在centos 7中更改nginx根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56923230/

相关文章:

php - 在 wordpress 主题中添加 the_post_thumbnail 作为 CSS 背景

json - 拒绝对 Nginx 中特定路径的所有 json 文件的请求

使用 NTLM 的 Windows 身份验证的 nginx 反向代理

google-cloud-platform - Google Cloud Centos 7 图像加载失败 - 没有 '/dev/log' 或 'logger' 用于 syslog 日志记录”

linux - 像生产服务器一样设置 Vagrant box

php - 如何使用 mysql 在 PHP 中循环获取查询

javascript - 如何处理 HTML 表单?

php - 结合Mysql Join的结果

ssl - 在 AWS NLB 后面的 nginx 集群中共享 SSL session

arrays - ubuntu上shell中的数组问题