nginx: [emerg] 未知指令 ""在/etc/nginx/sites-enabled/example.com:3 [英] nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/example.com:3

查看:17
本文介绍了nginx: [emerg] 未知指令 ""在/etc/nginx/sites-enabled/example.com:3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注了这个网站 http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver 在我的 Raspberry Pi 上设置 HTTP 服务器 nginx 并尝试设置站点调用 example.com.但是当我运行 sudo service nginx restart 时,它说

I have followed this website http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver to setup the HTTP server nginx on my Raspberry Pi and try to setup a site call example.com. But when I run sudo service nginx restart, it said

重新启动nginx:nginx:[emerg]未知指令"在/etc/nginx/sites-enabled/example.com:3

Restarting nginx: nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/example.com:3

这是 example.com 中的代码.

    server {

    server_name example.com 192.168.1.88;

    access_log /srv/www/example.com/logs/access.log;

    error_log /srv/www/example.com/logs/error.log;

    root /srv/www/example.com/public/;

    location / {

        index index.php index.html index.htm;

        try_files $uri $uri/ /index.php?$args;

    }

    location ~ .php$ {

        include /etc/nginx/fastcgi_params;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public$fastcgi_script_name;

    }

    location /phpmyadmin {

        root /usr/share/;

        index index.php index.html index.htm;

        location ~ ^/phpmyadmin/(.+.php)$ {

            try_files $uri =404;

            root /usr/share/;

            fastcgi_pass unix:/var/run/php5-fpm.sock;

            fastcgi_index index.php;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

            include /etc/nginx/fastcgi_params;

        }

        location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {

            root /usr/share/;

        }

    }

    location /phpMyAdmin {

        rewrite ^/* /phpmyadmin last;

    }

}

我只是按照步骤操作,但无法成功运行.

I am just following the steps but it can't run successfully.

推荐答案

我遇到了同样的问题,我从网上复制/粘贴了配置代码和一些脏的 EOL(end of line) 字符所在的位置.

I had the same problem which was that I copy/pasted the config code from the web and some dirty EOL(end of line) characters where there.

编辑器没有显示它们,但 nginx 将它们视为指令.

The editor didn't show them, but nginx treated them like a directive.

刚刚删除了每个EOL并重新添加.

Just deleted every EOL and added again.

这篇关于nginx: [emerg] 未知指令 ""在/etc/nginx/sites-enabled/example.com:3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆