Centos-Nginx 使用

CentOS 使用 Nginx。

安装

1
2
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx

配置文件

修改文件:

1
2
3
/usr/local/etc/nginx/nginx.conf

/etc/nginx/nginx.conf

内容为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
listen 8888;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://127.0.0.1:18888;
proxy_redirect off;
proxy_set_header Host $host:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

启动

1
2
3
#启动文件设置开机启动
vi /etc/rc.d/rc.local
nginx