我是NGINX的新手,我正在尝试设置最小的工作量.所以我试图用nginx和supervisor运行aiohttp mini-app(通过这个例子).但我无法正确配置Nginx并收到以下错误:
nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1
Run Code Online (Sandbox Code Playgroud)
这是完整的default.conf文件:
http {
upstream aiohttp {
# Unix domain servers
server unix:/tmp/example_1.sock fail_timeout=0;
server unix:/tmp/example_2.sock fail_timeout=0;
server unix:/tmp/example_3.sock fail_timeout=0;
server unix:/tmp/example_4.sock fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server example.com;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://aiohttp;
}
}
}
Run Code Online (Sandbox Code Playgroud)
看起来很正确.server指令是http应该的.http是父指令.我做错了什么?
我已经关注这个网站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; …Run Code Online (Sandbox Code Playgroud)