linux下nginx快速安装配置

1、linux安装nginx: yum install nginx
2、配置nginx.conf
找到config文件:
find / -name 'nginx.conf'
在http里添加以下配置:

upstream 应用名{
server 114.55.227.85:18080;
}
server {
 listen  80;
 server_name www.example.com;
 root /web/htdocs;

 location / {
  proxy_pass http://应用名;
  index index.html index.htm;
 }

 location /status {
  stub_status on;
  allow 10.0.0.0/8;
  deny all;
  access_log off;
 }

}

3、修改/etc/nginx/conf.d/default.conf
此时启动nginx报错:

[root@xxxxxx nginx]# nginx 
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

修改default.conf文件后可以解决 http://blog.csdn.net/reblue520/article/details/52799500
将listen 80 default_server;listen [::]:80 default_server;改为:listen 80;#listen [::]:80 default_server;

4、启动nginx
输入nginx即可

5、若在启动后修改了nginx.conf,则重新加载即可
nginx -s reload

你可能感兴趣的:(linux下nginx快速安装配置)