文章参考至:https://www.cnblogs.com/liujuncm5/p/6713784.html
centos7安装nginx
官网下载
https://nginx.org/en/download.html
-
访问官网下载
tar.gz
安装包
-
使用wget命令下载(推荐)。确保系统已经安装了wget,如果没有安装,执行
yum install wget
安装。
wget -c https://nginx.org/download/nginx-1.20.1.tar.gz
解压缩
tar -zxvf nginx-1.20.1.tar.gz
cd nginx-1.20.1
配置
- 使用默认配置
./configure
- 自定义配置(不推荐)
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
注:将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
编译安装
make
make install
查看安装路径:
whereis nginx
启动、停止nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload