nginx启动失败如何解决
这篇文章主要介绍了nginx启动失败如何解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇nginx启动失败如何解决文章都会有所收获,下面我们一起来看看吧。
操作首先nginx不是自己部署,要先启动一下
dockerstartnginx
发现打印出了nginx 但是 docker ps 发现 nginx还是启动失败
于是准备查看日志
dockerlogs-fnginx
报了一堆错误,也不知道是什么时候打的日志,后来解决之后猜测是因为配置文件为空的原因,因为没有找到event模块
所以首先看一下nginx的容器信息
dockerinspectnginx
找到挂载信息了,可以看看配置文件,发现 /usr/nginx/conf 里面没有配置文件,这个时候就应该找到了问题;可是运维同学在查询问题的时候创建了一个空的nginx.conf,我没有打开配置文件
后来在老大的提醒下打开了配置文件发现是空的,然后就对配置文件进行了修改
先找了一个默认的nginx.conf的配置
#usernobody;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{worker_connections1024;}http{includemime.types;default_typeapplication/octet-stream;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#access_loglogs/access.logmain;sendfileon;#tcp_nopushon;#keepalive_timeout0;keepalive_timeout65;#gzipon;server{listen80;server_namelocalhost;#charsetkoi8-r;#access_loglogs/host.access.logmain;location/{roothtml;indexindex.htmlindex.htm;}#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{#proxythePHPscriptstoApachelisteningon127.0.0.1:80#location~\.php${#proxy_passhttp://127.0.0.1;#}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;#includefastcgi_params;#denyaccessto.htaccessfiles,ifApache'sdocumentroot#concurswithnginx'sone#location~/\.ht{#denyall;}#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration##server{#listen8000;#listensomename:8080;#server_namesomenamealiasanother.alias;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}#HTTPSserver#listen443ssl;#server_namelocalhost;#ssl_certificatecert.pem;#ssl_certificate_keycert.key;#ssl_session_cacheshared:SSL:1m;#ssl_session_timeout5m;#ssl_ciphersHIGH:!aNULL:!MD5;#ssl_prefer_server_cipherson;
然后docker start nginx 发现可以启动了
接下来增加正确的jira配置
location/{proxy_passhttp://192.168.1.111:8080;proxy_redirectoff;proxy_set_headerHost$host:$server_port;##重点在$server_portproxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_max_temp_file_size0;proxy_connect_timeout90;proxy_send_timeout90;proxy_read_timeout90;proxy_buffer_size4k;proxy_buffers432k;proxy_busy_buffers_size64k;proxy_hide_headerVary;proxy_set_headerAccept-Encoding'';proxy_set_headerReferer$http_referer;proxy_set_headerCookie$http_cookie;}
进入容器检测一下配置文件是否有问题
dockerexec-it容器id/bin/bash
nginx路径寻找 find / -name nginx
./nginx/sbin/nginx-t
检测发现少了一个}
:setnu
找到具体行,然后修复
ctrl+D//退出容器
启动nginx
dockerrestartnginx
关于“nginx启动失败如何解决”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“nginx启动失败如何解决”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。