官方:https://nginx.org/en/download.html
常用命令
进入目录下
cd /usr/local/nginx/sbin/
启动、指定配置文件启动
./nginx
./nginx -c /usr/local/nginx/conf/nginx.conf
若你的启动路径是自己写的,安装后,需要复制mime.types,用来让nginx识别配置文件,不然启动时会找不到
sudo cp /usr/local/nginx/conf/mime.types /home/lbw/
重新加载配置文件、加载指定的配置文件
./nginx -s reload
./nginx -s reload -c /usr/local/nginx/conf/nginx.conf
停止,若不好用就强制kill
./nginx -s stop
安全退出,若不好用就强制kill
./nginx -s quit
查看nginx进程、任意一个都可
ps aux|grep nginx
ps -ef | grep nginx | grep -v grep
sudo kill -TERM $(ps -ef | grep nginx | grep -v grep | awk '{print $2}')
sudo pkill -9 nginx
安装
安装依赖
sudo apt update
sudo apt install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev
将Nginx下载到本机,解压
sudo tar -zxvf nginx-1.28.0.tar.gz
进入解压后的目录,执行安装
cd ./nginx-1.28.0
安装
./configure
编译
sudo make
编译安装
sudo make install
检验
whereis nginx
进入安装路径
cd /usr/local/nginx/
成功界面
配置文件修改
理解框架示例:不能直接使用
# 全局配置
# 最大连接数
events {
worker_connections 1024;
}
#
http {
# http全局配置
# 负载均衡 服务器请求分配weight权重比例,当前为1:1 等于轮循
# upstream ce1 {
# server 127.0.0.1:8080 weight=1;
# server 127.0.0.1:8081 weight=1;
# }
#配置路由访问 根
location / {
root html;
index index.html index.htm;
# 配置反向代理
proxy_pass http://www.baidu.com;
}
# # 配置路由1访问
# location /admin {
# root html;
# index index.html index.htm;
# #
# proxy_pass http://
# }
}