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 时,它说

重启 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;

    }

}

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

原文由 Confucius 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 483
2 个回答

我有同样的问题,我从网上复制/粘贴了配置代码和一些脏的 EOL (行尾)字符。

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

只是删除了每个 EOL 并再次添加。

原文由 Andres Bott 发布,翻译遵循 CC BY-SA 4.0 许可协议

听起来您在这里做了一些复制和粘贴工作。在行尾 (EOL) 捕获一些不可见的额外字符并不少见。尝试这个:

通过此工具运行您的文本: http ://www.textfixer.com/tools/remove-line-breaks.php

然后修复任何可能已被删除并受评论影响的中断。

这对我有用。希望对你有效。

原文由 Philll_t 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题