按要求修改nginx配置文件,配置https的时候,发现报错了。
[root@localhost sbin]#
systemctl restart nginx Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
这才知道安装nginx的时候没有带上--with-http_ssl_module,导致无法将nginx配置文件修改为https的。
现在nginx已经安装,只是缺少了http_ssl_module
模块。
解决方法,补充缺失的模块:
1. cd /usr/local/nginx-1.21.1 找到当前路径
2.添加新配置
bash ./configure --prefix=/usr/local/nginx --with-http_ssl_module
3.运行完一定要make,而不是make install。
4.备份nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
5.停止正在运行的nginx进程
systemctl stop nginx
6.将编译好的nginx覆盖原有的nginx
cp ./objs/nginx /usr/local/nginx/sbin/
7.将nginx.conf配置文件中修改为https
8.验证conf文件是否存在问题
[root@localhost sbin]# ./nginx -t
如果配置文件中没有语法错误,将会显示 "nginx: configuration file /path/to/nginx.conf test is successful"。
9.重启nginx服务
systemctl start nginx
systemctl stauts nginx 查看运行状态