d 我登录到我的 EC2 控制台创建了一个新实例并为其附加了一个 Elastice IP。然后我登录到服务器并安装了 Nginx:
$ sudo apt-get install nginx
$ sudo /etc/init.d/nginx start
$ Starting nginx: nginx.
当我导航到弹性 IP(或公共 DNS)时,我什么也得不到。默认设置应该足以显示默认的 Nginx 欢迎页面,对吗?我碰壁了,不知道下一步该怎么做。我们欢迎所有的建议?
我没有碰过它,但这是我的默认 nginx.conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
访问日志或错误日志中没有任何内容,我还确保 nginx 正在运行:
ps -ax | grep nginx
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
4305 ? Ss 0:00 nginx: master process /usr/sbin/nginx
4306 ? S 0:00 nginx: worker process
4307 ? S 0:00 nginx: worker process
4308 ? S 0:00 nginx: worker process
4309 ? S 0:00 nginx: worker process
这里最有可能的问题是您需要在 EC2 安全组设置中打开端口 80,以便实例可以接受到 Web 服务器的入站流量。