我编写了nginx,想要启用push模块(http://pushmodule.slact.net/)来实现nginx彗星服务器。
当我尝试重启时,我得到: nginx:[emerg]未知指令“set”在/usr/local/nginx/conf/nginx.conf:43
这是我的conf:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
location /publish {
# Название переменной с идентификатором канала
# в нашем примере "cid", т.е. запрос будет таким:
# http://example.com/publish?cid=s42378fwe
set $push_channel_id $arg_cid;
push_publisher;
# Отключаем хранение очереди (сообщение удаляется после доставки)
push_store_messages off;
}
location /listen {
push_subscriber;
# Обслуживать только первого "слушателя"
# Остальным отправляем 403
push_subscriber_concurrency first;
# Идентификатор канала
set $push_channel_id $arg_cid;
# Тип ответа
default_type text/plain;
}
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
系统:ubuntu 10.10 x86。有人可以帮帮我吗?
答案 0 :(得分:3)
错误是因为nginx不知道位置/发布块中的命令“push_publisher”。推送模块不是您的特定nginx正在运行的构建的一部分。
您是否使用nginx下载并编译模块并将新编译的nginx安装到Ubuntu中的默认位置?
由于你的nginx.conf文件位于/ etc / nginx,我猜你正在运行aptitude(sudo apt-get install nginx)的默认nginx,它不包含push模块。从包含push模块的源代码下载并安装nginx,它应该可以工作。将它安装到您创建的“/ opt / nginx”之类的目录中,这样您就知道您不只是运行操作系统默认包。
答案 1 :(得分:2)
默认的nginx不支持"" HttpRewriteModule定义" set"指令"" ,你必须从源代码编译,安装和使用nginx: - 从here
下载nginx源代码./ configure --with - " module_to_add" 你可以用这种方式摆脱一些模块:
./ configure --without - " module_to_not_include"
例如模块" http_rewrite_module"需要“pcre”和“pcre-devel”安装它们或从编译中排除它(./configure --without-http_rewrite_module)
用于ssl模块:./ configure --with-http_ssl_module
安装新的nginx后,我们必须使用它而不是默认的: 新nginx的二进制文件位于:
/ usr / local / nginx / sbin(您可以尝试从那里运行)
sudo nano /etc/init.d/nginx
找到这两行:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nginx
是否将它们更改为:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/nginx/sbin
DAEMON=/usr/local/nginx/sbin/nginx
或者我建议评论旧的并添加新的,所以你最终得到:
#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/nginx/sbin
#DAEMON=/usr/sbin/nginx
DAEMON=/usr/local/nginx/sbin/nginx
(修改后,要保存并退出nano,按(Ctrl + O)然后按(Enter)然后按(Ctrl + x))
将旧的nginx配置备份到新的nginx(如果有的话)(复制粘贴nginx.conf)
设置配置:
cd / usr / local / nginx / sbin
sudo ./nginx -t -c /usr/local/nginx/conf/nginx.conf
重启nginx:
sudo /etc/init.d/nginx restart
或者您可以重启您的操作系统,而不是最后的拖车说明。 现在nginx支持"设置"指示。 希望这会有所帮助。