Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the failure of nginx startup

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to solve the problem of nginx startup failure, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe everyone will gain something after reading this article on how to solve the problem of nginx startup failure. Let's take a look at it together.

operation

First of all, nginx is not deployed by itself. It needs to be started first.

docker start nginx

Nginx found printed but docker ps found nginx or failed to start

So I'm ready to check the logs

docker logs -f nginx

A bunch of errors were reported. I don't know when the log was typed. After it was solved, I guessed that it was because the configuration file was empty, because the event module was not found.

So first take a look at nginx container information

docker inspect nginx

Found the mount information. You can look at the configuration file and find that there is no configuration file in/usr/nginx/conf. At this time, you should have found the problem. However, the operation and maintenance students created an empty nginx.conf when querying the problem. I did not open the configuration file.

Later, under the reminder of the boss, I opened the configuration file and found that it was empty, and then modified the configuration file.

First find a default configuration of nginx.conf

#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { # proxy the PHP scripts to Apache listening on 127.0.0.1:80 #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; # deny access to .htaccess files, if Apache's document root # concurs with nginx's one #location ~ /\.ht { # deny all; } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:! aNULL:! MD5; # ssl_prefer_server_ciphers on;

Then docker start nginx found that can be started

Next add the correct jira configuration

location / { proxy_pass http://192.168.1.111:8080; proxy_redirect off; proxy_set_header Host $host:$server_port; ##Focus on $server_port proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; }

Go into the container and check if there is a problem with the configuration file

docker exec -it containerid/bin/bash

find / -name nginx

./ nginx/sbin/nginx -t

The test found that one} was missing.

:set nu

Find specific lines and fix them

Ctrl +D //Exit container

start nginx

docker restart nginx About "How to solve nginx startup failure" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "how to solve nginx startup failure". If you still want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report