1、linux安裝nginx: yum install nginx
2、配置nginx.conf
找到config文件:
find / -name 'nginx.conf'
在http里添加以下配置:
upstream 應(yīng)用名{
server 114.55.227.85:18080;
}
server {
listen 80;
server_name www.example.com;
root /web/htdocs;
location / {
proxy_pass http://應(yīng)用名;
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
此時(shí)啟動(dòng)nginx報(bào)錯(cuò):
[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、啟動(dòng)nginx
輸入nginx即可
5、若在啟動(dòng)后修改了nginx.conf,則重新加載即可
nginx -s reload