nginx安装
Posted fourw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx安装相关的知识,希望对你有一定的参考价值。
配置nginx的yum源
vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
nginx -v
cd /etc/nginx/
vim nginx.conf#修改nginx主配置文件
cd /etc/nginx/conf.d/
cp default.conf my.conf
vi my.conf#定义新的服务器
listen 80 default_server;
server_name 192.168.2.188;
location /
root /usr/share/nginx/a;
index index.html index.htm;
cd /usr/share/nginx/
mkdir a
vim a/index.html
nginx#启动nginx
nginx -s stop#停止nginx
访问192.168.2.188
配置反向代理
vim /etc/nginx/conf.d/fzjh.conf
upstream tomcatsvr
server 192.168.30.17 weight=3;
server 192.168.30.27;
server
listen 80 default_server;
server_name 192.168.2.188;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /
proxy_pass http://tomcatsvr;
index index.html index.htm;
location /status
stub_status;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html
root /usr/share/nginx/html;
访问192.168.2.188
以上是关于nginx安装的主要内容,如果未能解决你的问题,请参考以下文章