我正在运行Amazon Linux AMI和nginx,当我尝试启动我的nginx服务器时:
$ sudo /etc/init.d/nginx restart
我收到以下错误:
nginx: [emerg]: bind() to IP failed (99: Cannot assign requested address)
其中“IP”是我的IP地址的占位符。有人知道为什么会发生错误吗?这是在EC2上运行。
我的nginx.conf文件如下所示:
user app;
worker_processes 4;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript application/xml application/xml+rss text/javascript;
server_names_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen IP:443;
server_name name;
include /etc/nginx/ssl.conf;
}
}
kirpit说:使用Amazon EC2和弹性IP,服务器实际上并不像大多数其他服务器那样知道它的IP。所以你需要告诉你的linux允许进程绑定到非本地地址。只需将以下行添加到/etc/sysctl.conf中,然后重新加载sysctl.conf。
但是在Amazon Linux AMI上bash: sysctl: command not found
答案 0 :(得分:5)
你能删除IP部分吗?
listen 443;
如果您有多个IP分配给服务器并且您希望nginx仅侦听该IP,则只需指定IP。