1、文件上传
用SSH- Secure或Xshell工具将nginx.xx.tar.gz,上传到Linux系统/home目录下
2、解压:tar xvf nginx-1.8.0.tar.gz
删除压缩包:rm -rf nginx-1.8.0.tar.gz
3、配置
进入nginx目录
cd nginx-1.8.0
./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx
这里指定安装的目录在:/opt/nginx目录下
- 报错:error: the HTTP rewrite module requires the PCRE library.
解决:安装pcre-devel
yum -y install pcre-devel
参考:https://blog.csdn.net/hybaym/article/details/50929958
4、编译安装
make && make install
5、启动:nginx
查看进程:ps -ef | grep nginx
6、关闭防火墙
chkconfig iptables off
service iptables stop --手动临时关闭
7、安装成功(在浏览器输入centos ip地址:192.168.x.x)
nginx配置代理(模板)
nginx.conf
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name manage.leyou.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://127.0.0.1:9001;
proxy_connect_timeout 600;
proxy_read_timeout 600;
}
}
server {
listen 80;
server_name api.leyou.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://127.0.0.1:10010;
proxy_connect_timeout 600;
proxy_read_timeout 600;
}
}
}
配置重启:nignx -s reload