Skip to content

安装

Terminal window
$ sudo apt update
$ sudo apt install nginx
Terminal window
# 预编译
$ ./configure
--sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-http_ssl_module
--with-pcre=../pcre2-10.39
--with-zlib=../zlib-1.3
# 编译
$ make
# 安装
$ make install
Terminal window
# 启动
$ nginx
# 验证
$ curl localhost
# 查看进程(master/worker)
$ ps -ef | grep nginx
# 查看80端口占用情况
$ lsof -i:80
# 查看版本、配置等信息
$ nginx -V
# 查看nginx配置文件路径(如果配置文件有问题则会报错)
$ nginx -t
# 优雅停止
$ nginx -s quit
# 立即停止
$ nginx -s stop
# 重载配置文件
$ nginx -s reload
# 重新打开日志文件
$ nginx -s reopen