【发布时间】:2013-10-10 13:14:45
【问题描述】:
我已关注此网站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;
}
}
我只是按照步骤操作,但无法成功运行。
【问题讨论】:
-
安装的是什么版本的nginx?根据这个网站,您使用 apt-get 获得的版本存在一些问题。 virtualitblog.blogspot.nl/2013/05/… 我可以建议添加 nginx.org apt 存储库并重新安装 nginx 吗?你也可以运行:ldd /usr/sbin/nginx 并将结果发布到 gist.github.com 的某个地方吗?
-
我已经使用
/usr/sbin/nginx -t -v来检查我使用的是 nginx/1.2.1,当我运行sudo apt-get install nginx时,我已经按照 http://nginx.org/en/linux_packages.html 将其添加到 apt sources.list 中返回 nginx 已经是最新版本了。。有一件事我忘了说,我可以去http://127.0.0.1/我可以看到默认站点(/usr/share/nginx/www/index.html)。 -
请选择最适合您的答案。谢谢。
标签: linux nginx raspberry-pi httpserver raspbian