首页 > 其他 > 详细

Nginx 安装配置

时间:2019-08-14 14:00:26      阅读:81      评论:0      收藏:0      [点我收藏+]
添加 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!