安装与配置
1、安装依赖(根据需要自行安装)
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2 解压
tar -xvf nginx-1.23.1.tar.gz
3 添加依赖 指定文件与配置路径
./configure --prefix=/usr/local/nginx-1.23.1 --conf-path=/usr/local/nginx-1.23.1/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
4 编译
make
5 安装
make install
6 配置
nginx.conf 把里面的 缓存配置路径改了以及基础 listen location配置
#缓存配置
proxy_cache_path /usr/local/nginx-1.23.1/cache levels=1:2 keys_znotallow=my_cache:200m max_size=10g inactive=7d use_temp_path=off;
7 指定配置文件启动
/usr/local/nginx-1.23.1/sbin/nginx -c /usr/local/nginx-1.23.1/nginx.conf
8 查看nginx进行
ps -ef | grep nginx
9 查看nginx监听端口
netstat -anp|grep nginx
9 配置nginx环境变量
/home/app/user/local/nginx-1.23.1/sbin nginx的bin目录
刷新环境配置文件
source /etc/profile
nginx运维
1、查看nginx安装位置
whereis nginx
2、重启nginx
cd /user/local/nginx/sbin
./nginx -s reload
3、查看nginx历史操作
cd /user/local/nginx/sbin
history
4、查看nginx依赖
nginx -V
5、停止nginx服务
kill -s 9 pid(master)
nginx平滑升级
升级nginx的版本,为nginx添加新的模块
查看当前版本
nginx -V
下载新的Nginx版本并编译。
wget nginx-1.0.11.tar.gz tar zxvf nginx-1.0.11.tar.gz cd nginx-1.0.11 ./configure --add-module=/customized_module_0 --add-module=/customized_module_1 make
备份老版本的可执行文件
cd /usr/local/nginx/sbin sudo cp nginx nginx.old
修改配置文件
如果有必要的话,进行配置文件的修改。
拷贝新的可执行文件
sudo cp /home/michael/tmp/nginx-1.0.11/objs/nginx /usr/local/nginx/sbin/
升级
cd /home/michael/tmp/nginx-1.0.11 make upgrade
清理多余文件
rm -rf /home/michael/tmp/nginx-1.0.11
查看Nginx版本
nginx -V
批量删除所有nginx服务
ps -ef | grep nginx | grep -v grep | awk '{ print $2}'|xargs kill -9