1、官网下载nginx
官网下载:http://nginx.org/en/download.html
随便选一个
2、安装依赖
sudo apt-get install gcc zlib1g zlib1g-dev libpcre3-dev openssl libssl-dev
3、解压安装
# 解压缩 tar -zxvf linux-nginx-1.16.6.tar.gz cd nginx-1.16.1/ # 执行配置 ./configure # 编译安装(默认安装在/usr/local/nginx) make make install
nginx配置文件路径/usr/local/nginx/conf/nginx.conf
启动/usr/local/nginx/sbin/nginx
显示上图即成功
nginx常用命令
在nginx安装目录下:(默认/usr/local/nginx
)
测试配置文件:sbin/nginx -t
启动命令:sbin/nginx
停止命令:sbin/nginx -s stop
停止命令:sbin/nginx -s quit
重启命令:sbin/nginx -s reload
查看进程命令:ps -ef | grep nginx
平滑重启:kill -HUP Nginx主进程号(即ps命令查到的PID)