添加 nginx 的 yum 源
sudo rpm -Uvh
http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release
centos-7-0.el7.ngx.noarch.rpm
安装gcc gcc-c++(如新环境,未安装请先安装)
$ yum install -y gcc gcc-c++
安装Nginx
sudo yum install -y nginx
Nginx配置信息
/etc/nginx/nginx.conf
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr - $remote_user
[$time_local] "$request" ‘
‘$status $body_bytes_sent
"$http_referer" ‘
‘"$http_user_agent"
"$http_x_forwarded_for"‘;
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8099/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header Request-Url $request_uri;
}
location ~
.*\.(woff2|html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /root/static/ops;
access_log on;
index index.html index.htm;
}
}
server {
listen 88;
location / {
proxy_pass http://127.0.0.1:8099/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP
$remote_addr;proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header Request-Url $request_uri;
}
location ~
.*\.(woff2|html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /root/static/biz;
access_log on;
index index.html index.htm;
}
}
}
启动Nginx
# cd /etc/nginx/
#nginx -c nginx.conf
Nginx 安装配置
原文:https://www.cnblogs.com/dage2587/p/11351448.html