Linux安装Nginx 发表于 2022-04-06 更新于 2023-03-07 分类于 Nginx 本文字数: 238 阅读时长 ≈ 1 分钟 1、安装所需环境1234567891011//安装gccyum install gcc-c++//安装PCRE pcre-develyum install -y pcre pcre-devel//安装zlibyum install -y zlib zlib-devel//安装Open SSLyum install -y openssl openssl-devel 2、创建nginx目录并下载安装包1234567891011121314//进入usr/local目录cd /usr/local//创建nginx目录mkdir nginx//进入nginx目录cd nginx//下载tar包wget http://nginx.org/download/nginx-1.22.1.tar.gz//解压tartar -xvf nginx-1.22.1.tar.gz 3、安装nginx1234567891011//进入nginx目录cd /usr/local/nginx/nginx-1.22.1//执行命令./configure//执行make命令(要是执行不成功请检查最开始安装的四个有没有安装成功)make//执行make install命令make install 4、启动nginx1234567891011//进入/usr/local/nginx/sbin目录,输入./nginx即可启动nginx./nginx//关闭nginx./nginx -s quit 或者 ./nginx -s stop//重启nginx./nginx -s reload//查看nginx进程ps -ef|grep nginx 5、设置开启自启动12345//编辑vim /etc/rc.local//最底部增加这一行/usr/local/nginx/sbin/nginx 6、日志路径1/var/log/nginx