VPS侦探论坛

 找回密码
 注册
查看: 13171|回复: 3

军哥,配置openssl出现错误nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/www.mydo

[复制链接]
发表于 2017-4-6 22:36:25 | 显示全部楼层 |阅读模式

军哥,配置openssl出现错误nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/www.mydomain.com.crt") failed

军哥,按照这篇教程配置ssl出现了错误:(参考教程)https://www.vpser.net/manage/namecheap-free-ssl-nginx.html
到这一步出现了错误
然后执行/usr/local/nginx/sbin/nginx -t 检查配置是否有错误,执行/usr/local/nginx/sbin/nginx -s reload 重新载入配置文件使其生效。
错误显示:
[root@domain conf]# /usr/local/nginx/sbin/nginx -t
nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/www.mydomain.com.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/usr/local/nginx/conf/www.mydomain.com.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@domain conf]# lnmp nginx restart  




nginx里面的error.log显示的大量错误如下:

  1. 2017/03/27 11:41:01 [warn] 6809#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  2. 2017/03/27 11:45:08 [warn] 6820#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  3. 2017/03/27 11:45:08 [notice] 6820#0: signal process started
  4. 2017/03/27 11:45:09 [warn] 6825#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  5. 2017/03/27 11:54:17 [warn] 6835#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  6. 2017/03/27 11:54:17 [notice] 6835#0: signal process started
  7. 2017/03/27 11:54:18 [warn] 6840#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  8. 2017/03/27 12:34:38 [emerg] 6925#0: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:129
  9. 2017/03/27 12:44:33 [emerg] 6940#0: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:129
  10. 2017/03/27 12:58:01 [emerg] 6953#0: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:131
  11. 2017/03/28 05:22:28 [emerg] 7367#0: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:155
  12. 2017/03/28 05:26:29 [emerg] 7381#0: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:155
  13. 2017/03/28 05:57:23 [warn] 7394#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  14. 2017/03/28 05:57:23 [notice] 7394#0: signal process started
  15. 2017/03/28 05:57:24 [warn] 7399#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
  16. 2017/03/28 05:58:27 [warn] 7409#0: conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
复制代码




自己的nginx.conf配置如下:




user www www;

worker_processes auto;

error_log /home/wwwlogs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
multi_accept on;
}

http
{
map $http_cf_ipcountry $allow {
default yes;
CN yes;
RU no;
US yes;
}
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

server_tokens off;
access_log off;

server
{
if ($allow = no) {
return 403;
}


location / {
add_header 'Access-Control-Allow-Origin' 'https://www.mydomain.com';
}


add_header Content-Security-Policy upgrade-insecure-requests;
add_header 'Access-Control-Allow-origin' 'https://www.mydomain.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST';
# Cross domain webfont access
location = /favicon.ico { log_not_found off; access_log off; }

location = /robots.txt { log_not_found off; access_log off; allow all; }

location ~* .(ogg|ogv|mp4|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
add_header "Access-Control-Allow-Origin" "https://www.mydomain.com";
add_header "Timing-Allow-Origin" "*";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
expires max;
log_not_found off;
}

location ~* .(ttf|ttc|otf|eot|woff|woff2|svg|svgz)$ {
add_header "Access-Control-Allow-Origin" "https://www.mydomain.com";
add_header "Timing-Allow-Origin" "*";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
expires max;
log_not_found off;
}

listen 80 default_server;
listen 443 default_server;

ssl on;
#listen [::]:80 default_server ipv6only=on;
server_name www.mydomain.com;

ssl_certificate /usr/local/nginx/conf/www.mydomain.com.crt;   
ssl_certificate_key /usr/local/nginx/conf/www.mydomain.com.key;

return 301 https://www.mydomain.com$request_uri;index index.html index.htm index.php;
root /home/wwwroot/default;

#error_page 404 /404.html;
include enable-php.conf;

location /nginx_status
{
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}



location ~ /\.
{
deny all;
}


access_log /home/wwwlogs/access.log;
}
include vhost/*.conf;
}


[ 本帖最后由 fasefe 于 2017-4-6 22:52 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-4-7 14:18:32 | 显示全部楼层


nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/www.mydomain.com.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/usr/local/nginx/conf/www.mydomain.com.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)

这里已经说了文件不存在
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-4-7 19:01:08 | 显示全部楼层

回复 2# 的帖子


谢谢,搞定了,重新配置
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-2-22 22:50:16 | 显示全部楼层



楼主你应该帖出你的解决方法,让后面出问题的同学可以学习一下!今天我就遇到了这个问题,最后不得已重装了lnmp才解决,折腾了一晚上~才好
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-18 21:48 , Processed in 0.026902 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表