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のコメント:AmazonEC2とElasticIPを使用すると、サーバーは他のほとんどのサーバーとは異なり、実際にはIPを認識しません。したがって、プロセスが非ローカルアドレスにバインドできるようにLinuxに指示する必要があります。次の行を/etc/sysctl.confに追加してから、sysctl.confをリロードします。
しかし、AmazonLinuxAMIではbash: sysctl: command not found