Shawn's Blog
蒸汽兔
nginx相关笔记
字数:360 字
阅读时长:约 2 分钟
阅读次
安装
前期准备 - 下载文件
下载地址: http://nginx.org/en/download.html
本次下载版本文件:nginx-1.20.1.tar.gz
linux 服务器操作
安装nginx所需依赖
# pcre
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo apt-get install aptitude
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo apt-get install libpcre3
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo aptitude install libpcre3-dev
# zlib
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo apt-get install zlib1g-dev
# openssl
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo apt-get install openssl
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ sudo apt-get install libssl-dev
执行安装
# 解压文件
ubuntu@VM-0-4-ubuntu:~/soft/nginx$ tar -zxvf nginx-1.20.1.tar.gz
nginx-1.20.1/
nginx-1.20.1/auto/
nginx-1.20.1/conf/
nginx-1.20.1/contrib/
nginx-1.20.1/src/
# 进入解压目录
ubuntu@VM-0-4-ubuntu:~/soft/nginx$ cd nginx-1.20.1/
# 执行命令
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ ./configure # 不带https模块
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ ./configure --with-http_ssl_module # 带https模块
# 编译
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ make
# 安装
# 默认安装目录需要root权限, 如果需要指定安装目录则使用命令`make install -p=${指定安装目录}`
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ make install
nginx 问题
现象:
https ngx_http_ssl_module
模块未安装, 启动ssl报错nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:99
在安装前就可以提前安装https模块
解决:
# 停止nginx
ubuntu@VM-0-4-ubuntu:/usr/local/nginx/sbin$ ./nginx -s stop
# 切换到源码包:
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ cd /home/ubuntu/soft/nginx/nginx-1.20.1
# 运行命令,配置
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ ./configure --with-http_ssl_module
# 编译
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ make
# 备份原有nginx运行文件
ubuntu@VM-0-4-ubuntu:/usr/local/nginx/sbin$ sudo cp nginx nginx-bak
# 将刚刚编译好的nginx覆盖掉原有的nginx
ubuntu@VM-0-4-ubuntu:~/soft/nginx/nginx-1.20.1$ mv ./objs/nginx /usr/local/nginx/sbin
# 现有nginx sbin目录
ubuntu@VM-0-4-ubuntu:/usr/local/nginx/sbin$ ll
total 10032
drwxr-xr-x 2 root root 4096 Aug 20 08:53 ./
drwxr-xr-x 11 root root 4096 Aug 19 17:15 ../
-rwxrwxr-x 1 ubuntu ubuntu 5457872 Aug 20 08:50 nginx*
-rwxr-xr-x 1 root root 4801256 Aug 20 08:52 nginx-bak*
# 启动
ubuntu@VM-0-4-ubuntu:/usr/local/nginx/sbin$ sudo ./nginx
# 查看状态
ubuntu@VM-0-4-ubuntu:/usr/local/nginx/sbin$ ps -ef|grep nginx
root 28429 1 0 08:55 ? 00:00:00 nginx: master process ./nginx
nobody 28430 28429 0 08:55 ? 00:00:00 nginx: worker process
ubuntu 28863 24081 0 08:55 pts/2 00:00:00 grep --color=auto nginx
上一页
下一页