我已经关注这个网站http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver在我的Raspberry Pi上设置HTTP服务器nginx并尝试设置一个站点调用example.com。但是,当我运行sudo service nginx restart
时,它说
在/etc/nginx/sites-enabled/example.com:3重新启动nginx:nginx:[emerg] unknown指令“”
这是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;
}
}
我只是按照步骤,但它无法成功运行。
我有同样的问题,那就是我从网上复制/粘贴配置代码和一些脏的EOL
(行尾)字符。
编辑没有展示它们,但nginx
将它们视为指令。
刚删除每个EOL
并再次添加。
听起来你在这里做了一些复制和粘贴工作。在行尾(EOL)隐藏一些不可见的额外字符并不罕见。试试这个:
通过此工具运行您的文本:http://www.textfixer.com/tools/remove-line-breaks.php
然后修复可能已删除的任何中断并受注释影响。
这对我有用。希望对你有效。
看起来nginx二进制文件是使用--without-http_fastcgi_module选项编译的。这不是默认值。尝试下载或编译不同的二进制文件。
试试跑步
nginx -V
(使用大写V)查看用于编译nginx的选项。
我在conf文件的中间编辑了一些文本,nginx在文件本身的开头显示了这个错误。我复制了文件的内容,创建了一个新文件,粘贴了那里的内容,nginx停止显示这个错误。