LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 07-11-2020, 02:30 PM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,807

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Raspbian (Stretch): systemd not starting nginx


Today was supposed to be "Get Certbot Up And Running Day" but it's turned into yet another systemd headache. [sigh]

The topic is a good summary: When I boot an RPi on our network, the nginx service does not start. All of the service files being used are unchanged (by me) from the default Stretch installation---except for any subsequent updates.

I've done:
Code:
# systemctl enable nginx.service
and "chkconfig" shows that it's "on" but, following a reboot, I see no nginx processes. If I check the service's status, I get:
Code:
# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-07-11 12:22:52 CDT; 7min ago
     Docs: man:nginx(8)
  Process: 472 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Jul 11 12:22:51 vger2 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 11 12:22:52 vger2 nginx[472]: nginx: [emerg] host not found in upstream "testsite.mydomain.net:80" in /etc/nginx/sites-enabled/testmydomainnet.conf:5
Jul 11 12:22:52 vger2 nginx[472]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 11 12:22:52 vger2 systemd[1]: nginx.service: Control process exited, code=exited status=1
Jul 11 12:22:52 vger2 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jul 11 12:22:52 vger2 systemd[1]: nginx.service: Unit entered failed state.
Jul 11 12:22:52 vger2 systemd[1]: nginx.service: Failed with result 'exit-code'.
I can successfully start the process by hand using:
Code:
# /etc/init.d/nginx start
or
Code:
# systemctl start nginx.service
Either way I start it, I can verify that the service is up and running:
Code:
# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-07-11 12:31:07 CDT; 26s ago
     Docs: man:nginx(8)
  Process: 842 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 839 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 843 (nginx)
    Tasks: 5 (limit: 4915)
   CGroup: /system.slice/nginx.service
           ├─843 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ├─844 nginx: worker process
           ├─845 nginx: worker process
           ├─846 nginx: worker process
           └─847 nginx: worker process

Jul 11 12:31:06 vger2 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 11 12:31:07 vger2 systemd[1]: Started A high performance web server and a reverse proxy server.
Thinking that it was complaining that the test server was not running apache at the time, from the RPi, I verified that it was:
Code:
# nmap testsite.mydomain.net
Starting Nmap 7.40 ( https://nmap.org ) at 2020-07-11 12:32 CDT
Nmap scan report for testsite.mydomain.net (192.168.13.7)
Host is up (0.00013s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
111/tcp  open  rpcbind
2049/tcp open  nfs
MAC Address: D4:3D:7E:DF:2D:45 (Micro-Star Int'l)

Nmap done: 1 IP address (1 host up) scanned in 2.31 seconds
That server is pingable by name so it does not appear to be a DNS problem. I also can reach the test web server -- once nginx has been started by hand -- using any browser I point at it.

The nginx configuration seems healthy:
Code:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# /etc/init.d/nginx testconfig
[ ok ] Testing nginx configuration:.
If I take a look at the systemd logging ("journalctl -xe"), I can see where the first attempt, at boot, failed and where the manual startup succeeded.

Though I'm not sure why the nginx startup is behaving differently at boot than it is when I'm at a command prompt, I though debugging nginx might provide some insight. The Raspbian nginx was compiled with debug support so I added a little config file in /etc/nginx/conf.d containing:
Code:
error_log /var/log/nginx/debugging.log debug;
and reloaded the nginx config. I have a debugging.log file but restarting the nginx service or rebooting never places anything in it: still sitting there with 0 bytes.


Anything else I should be checking to see why the systemd is having trouble starting this service?

TIA...

Last edited by rnturn; 07-11-2020 at 09:23 PM. Reason: Added bit about attempting to debug nginx.
 
Old 07-12-2020, 12:48 AM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,807

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by rnturn View Post
Today was supposed to be "Get Certbot Up And Running Day" but it's turned into yet another systemd headache. [sigh]

.
.
.

Though I'm not sure why the nginx startup is behaving differently at boot than it is when I'm at a command prompt, I though debugging nginx might provide some insight. The Raspbian nginx was compiled with debug support so I added a little config file in /etc/nginx/conf.d containing:
Code:
error_log /var/log/nginx/debugging.log debug;
and reloaded the nginx config. I have a debugging.log file but restarting the nginx service or rebooting never places anything in it: still sitting there with 0 bytes.
Debugging was a bust. I've made the debugging config file hidden (for later use).

It was suggested (elsewhere) that nginx might be starting up too early and that, I'm assuming since the nginx config files were defining systems using FQDNs instead of IP addresses, that the service file needed to wait for some other service (probably bind9) to finish startup. I took the approach that nginx should just wait for everything needed for the multi-user target and modified nginx's service contain:
Code:
[Unit]
#After=network.target
After=multi-user.target

[Install]
#Wants=multi-user.target
and it now starts without problems at boot. Until, that is, some future systemd change comes along to make things, um, interesting again.

Later...
 
Old 07-12-2020, 08:46 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Kudos. Please mark this thread as [solved], since you solved the problem .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Raspbian GNU/Linux upgrade from Stretch to Raspbian Buster 10 LXer Syndicated Linux News 0 07-26-2019 06:12 PM
USB joystick, detected in ubuntu but not by raspbian stretch haemogoblin Linux - Hardware 10 08-01-2018 05:20 AM
LXer: Raspbian GNU/Linux upgrade from Jessie to Raspbian Stretch 9 LXer Syndicated Linux News 0 03-01-2018 07:50 PM
LXer: Raspbian GNU/Linux upgrade from Wheezy to Raspbian Jessie 8 LXer Syndicated Linux News 1 06-09-2016 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 11:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration