配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:107

简介:

在配置nginx 虚拟机时,执行

sudo /usr/sbin/nginx -t

报下面的错误:

nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:107
nginx: configuration file /etc/nginx/nginx.conf test failed

 

错误原因是:在配置文件时,访问路径设置了两个,重复配置webroot路径导致,去掉一个就可以了。

 

复制代码
server {
        listen 80 default_server;

        #root /usr/share/nginx/html/;去掉这行
        index index.html index.htm;
        # Make site accessible from http://localhost/
        root /home/wangkongming/webroot/blogs;

        index index.html index.htm;
        server_name blogs.local;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        access_log /data/logs/blogs/access.log;
        error_log /data/logs/blogs/error.log;

}
复制代码

 

转自:https://www.cnblogs.com/wangkongming/p/4290520.html

目录
相关文章
|
9月前
|
应用服务中间件 网络安全 nginx
Nginx配置SSL证书时——nginx:[emerg]unknowndirectivessl错误
Nginx配置SSL证书时——nginx:[emerg]unknowndirectivessl错误
1545 0
|
3月前
|
应用服务中间件 nginx
Nginx里的root和alias的区别是什么?
Nginx里的root和alias的区别是什么?
351 2
|
4月前
|
网络协议 应用服务中间件 nginx
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
这篇文章讨论了在使用nginx-rtmp-module进行RTMP推流时遇到的“Server error: Already publishing”错误,分析了错误原因,并提供了详细的解决办法,包括修改nginx配置文件和终止异常的TCP连接。
300 0
FFmpeg错误笔记(一):nginx-rtmp-module推流出现 Server error: Already publishing
|
6月前
|
存储 应用服务中间件 nginx
成功解决:nginx: [emerg] unexpected “}“ in /etc/nginx/conf.d/gulimall.conf:10
这篇文章详细介绍了Linux虚拟机磁盘空间不足时的扩容流程,从外部配置到具体扩容操作,再到验证扩容效果的步骤。同时,也探讨了Docker容器磁盘空间耗尽的问题,并提供了解决方案,包括删除无用镜像和容器,以及如何重新配置Docker的存储位置。文章还涵盖了一些意外情况的处理方法,比如误删容器后的恢复策略,并最终展示了使用Docker安装nginx并成功访问的详细过程。
成功解决:nginx: [emerg] unexpected “}“ in /etc/nginx/conf.d/gulimall.conf:10
|
6月前
|
JavaScript 应用服务中间件 PHP
nginx server 禁止特定目录下的某类文件访问
【8月更文挑战第26天】这段Nginx配置代码旨在保护`/uploads/`目录下的文件,禁止执行任何`.php`, `.html`, `.htm`, 或 `.js`等潜在有害文件,即便被访问也无法运行。取而代之的是重定向到首页。为了实现这一设置,用户需要定位到对应子域名的`.conf`配置文件中进行相应修改。若网站支持多个访问域名,则需确保在正确的`.conf`文件中实施此配置。
135 1
|
7月前
|
JSON 应用服务中间件 nginx
Nginx的server块和location块的简单说明
Nginx的server块和location块的简单说明
|
8月前
|
tengine 安全 应用服务中间件
修改Nginx/Tengine版本名称伪装任意WEB SERVER
修改Nginx/Tengine版本名称伪装任意WEB SERVER
128 1
|
9月前
|
安全 Ubuntu 应用服务中间件
【报错】ubutun下启动nginx失败:500 internal server error
【报错】ubutun下启动nginx失败:500 internal server error
699 0
|
9月前
|
弹性计算 算法 应用服务中间件
倚天使用|Nginx性能高27%,性价比1.5倍,基于阿里云倚天ECS的Web server实践
倚天710构建的ECS产品,基于云原生独立物理核、大cache,结合CIPU新架构,倚天ECS在Nginx场景下,具备强大的性能优势。相对典型x86,Http长连接场景性能收益27%,开启gzip压缩时性能收益达到74%。 同时阿里云G8y实例售价比G7实例低23%,是Web Server最佳选择。
|
9月前
|
应用服务中间件 网络安全 nginx
解决nginx:[emerg]unknown directive ssl错误
解决nginx:[emerg]unknown directive ssl错误
1814 0