centos7 安装nginx

1,nginx的安装
1>,添加CentOS 7 Nginx yum资源库
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2>,安装 yum install nginx
3>,启动 service nginx start
3>,停止 service nginx stop
3>,重载 service nginx reload

2,目录位置
/etc/nginx/

3,配置文件位置
/etc/nginx/nginx.conf
/etc/nginx/conf.d/default.conf 里面包含加载项目目录、端口、项目名、集群、负载均衡等常规配置

4,项目目录
/usr/share/nginx/html


5,伪静态

/etc/nginx/conf.d/文件项目配置中配置
location / {
rewrite ^(.*)\.htmp$ /index.html
}

6,日志
文件项目配置中配置 log_format
在nginx.conf中定义日志格式,然后在虚拟主机的conf文件中用access_log指定单独记录的日志地址和引用的格式名称

7,代理
8,负载均衡

http {
upstream myproject {
server 127.0.0.1:8000 weight=3;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}

server {
listen 80;
server_name www.domain.com;
location / {
proxy_pass http://myproject;
}
}
}
posted @ 2020-04-14 18:30  留住一秒去怀疑  阅读(163)  评论(0编辑  收藏  举报