nginx配置https以及出现的各种问题

3 篇文章 0 订阅

1.进入到nginx安装目录-看到nginx${版本号}的目录,会有configure文件在这里插入图片描述
然后执行

./configure --prefix=/usr/local/nginx-1.9.9 --add-module=…/lua-nginx-module-0.10.10/ --with-http_ssl_module

然后执行

make

出现:make: *** 没有规则可以创建“default”需要的目标“build”。 停止。
在这里插入图片描述

看是否是缺失依赖

yum install pcre-devel zlib zlib-devel openssl openssl-devel

在这里插入图片描述
然后修改nginx.conf配置文件
编辑 /usr/local/nginx/conf/nginx.conf

 server {
        listen       443 ssl;
        server_name  域名;

        ssl_certificate     pem所在位置;
        ssl_certificate_key  key所在位置;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

    	
         location /wxapi/ {       #代理
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://127.0.0.1:8000/;
			client_max_body_size 20m;
        }

     }

保存并退出文件,启动nginx:./nginx

启动报错:the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/nginx.conf:135在这里插入图片描述
解决方案:

进入安装源包位置源码包

cd /usr/local/nginx-1.9.9/nginx-1.9.9

查看所安装的模块中是否存在:http_ssl_module

/usr/local/nginx/sbin/nginx -V

在这里插入图片描述

添加:http_ssl_module

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

在这里插入图片描述

运行

make

在这里插入图片描述

备份原有已安装好的nginx

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

然后将刚刚编译好的nginx覆盖掉原有的nginx

cp ./objs/nginx /usr/local/nginx/sbin/

在这里插入图片描述

再次查看模块

/usr/local/nginx/sbin/nginx -V

在这里插入图片描述
然后再次启动
报错:nginx: [emerg] open() "/usr/local/nginx/conf/nginx.conf" failed (2: No such file or directory)
在这里插入图片描述
我的nginx.conf在nginx目录下
在这里插入图片描述

解决方案:创建conf文件夹,软连接nginx.conf
在这里插入图片描述

 ln -s /usr/local/nginx/nginx.conf /usr/local/nginx/conf/

启动:./nginx -s reload
报错:nginx: [emerg] open() "/usr/local/nginx/conf/mime.types" failed (2: No such file or directory) in /usr/local/nginx/conf/nginx.conf:18
在这里插入图片描述
解决方案:
在nginx.conf中指定mime.types的位置
在这里插入图片描述

在这里插入图片描述
启动,报错:nginx: [alert] kill(18991, 1) failed (3: No such process)
在这里插入图片描述
解决方案:
执行1:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
执行2:./nginx -s reload
在这里插入图片描述

启动成功了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值