我遵循了这个网站http://raspberrypihelp.net/tutorials/24-raspberry-pi-webserver来在我的Raspberry Pi上设置HTTP服务器nginx并尝试建立一个名叫example.com的网站。但是当我运行sudo service nginx restart
时,它显示:
重新启动nginx:nginx:[emerg] /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;
}
}
我只是按照步骤操作,但它无法成功运行。
/usr/sbin/nginx -t -v
命令来检查我正在使用 nginx/1.2.1 版本,我按照 http://nginx.org/en/linux_packages.html 的指示将其添加到 apt sources.list 中,当我运行sudo apt-get install nginx
时,它返回 nginx 已经是最新版本。有一件事我忘了说,就是我可以访问 http://127.0.0.1/ 并看到默认站点 (/usr/share/nginx/www/index.html)。 - Confucius