nginx fails to start - troubleshoot - nginx

I have a simple nginx config that is syntactically correct. I install nginx using chef and the chef script works fine.
But as I check status of nginx , I see it is in failed state. If I reload nginx , it again goes in failed state. journalctl -xn also doesnt give much of error except :
[root#localhost vagrant]# journalctl -xn
-- Logs begin at Wed 2016-10-26 04:28:18 UTC, end at Wed 2016-10-26 04:45:00 UTC. --
Oct 26 04:45:00 localhost.localdomain kill[17003]: -s, --signal <sig> send specified signal
Oct 26 04:45:00 localhost.localdomain kill[17003]: -q, --queue <sig> use sigqueue(2) rather than kill(2)
Oct 26 04:45:00 localhost.localdomain kill[17003]: -p, --pid print pids without signaling them
Oct 26 04:45:00 localhost.localdomain kill[17003]: -l, --list [=<signal>] list signal names, or convert one to a name
Oct 26 04:45:00 localhost.localdomain kill[17003]: -L, --table list signal names and numbers
Oct 26 04:45:00 localhost.localdomain kill[17003]: -h, --help display this help and exit
Oct 26 04:45:00 localhost.localdomain kill[17003]: -V, --version output version information and exit
Oct 26 04:45:00 localhost.localdomain kill[17003]: For more details see kill(1).
Oct 26 04:45:00 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Oct 26 04:45:00 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
[root#localhost vagrant]#
nginx -t is successful and I see nothing in /var/log/nginx/errors.log
Is there any other way to troubleshoot exactly why this fails ?
Both systemctl status nginx.service gives:
[root#localhost vagrant]# systemctl status nginx.service
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; static)
Active: failed (Result: exit-code) since Wed 2016-10-26 04:45:00 UTC; 9h ago
Process: 17003 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
Process: 16999 ExecStart=/opt/nginx-1.10.1/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 16998 ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 16999 (code=exited, status=0/SUCCESS)
Oct 26 04:45:00 localhost.localdomain kill[17003]: -s, --signal <sig> send specified signal
Oct 26 04:45:00 localhost.localdomain kill[17003]: -q, --queue <sig> use sigqueue(2) rather than kill(2)
Oct 26 04:45:00 localhost.localdomain kill[17003]: -p, --pid print pids without signaling them
Oct 26 04:45:00 localhost.localdomain kill[17003]: -l, --list [=<signal>] list signal names, or convert one to a name
Oct 26 04:45:00 localhost.localdomain kill[17003]: -L, --table list signal names and numbers
Oct 26 04:45:00 localhost.localdomain kill[17003]: -h, --help display this help and exit
Oct 26 04:45:00 localhost.localdomain kill[17003]: -V, --version output version information and exit
Oct 26 04:45:00 localhost.localdomain kill[17003]: For more details see kill(1).
Oct 26 04:45:00 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Oct 26 04:45:00 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
systemctl cat nginx.service gives :
[root#virsinplatformapi02 sysadmin]# systemctl cat nginx.service
Unknown operation 'cat'.
I cd cd /lib/systemd/system and do cat on nginx.service:
[root#virsinplatformapi02 system]# cat nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t
ExecStart=/opt/nginx-1.10.1/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
If I do a echo $MAINPID , I get nothing.

That is not very good unitfile. Type is not set and defaults to simple, while you want to you forking for nginx. That may be the reason for the wrong $MAINPID value. Try to use official unit:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t
ExecStart=/opt/nginx-1.10.1/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
You should just add it to /etc/systemd/system/nginx.service - that directory it intended for administrator-created units, and has priority.

Related

radiusd.service: Control process exited, code=exited status=1

I am very new to linux and freeradius and want to learn about this for my work, however I encounter some challenges.
I have installed freeradius on Centos 8. I installed it and it worked just fine but after installing mariaDB, issues came out when trying to start the service.
[root#FPM-FreeRad01 ~]# systemctl start radiusd.service
Job for radiusd.service failed because the control process exited with error code.
See "systemctl status radiusd.service" and "journalctl -xe" for details.
[root#FPM-FreeRad01 ~]# systemctl status radiusd.service
â radiusd.service - FreeRADIUS high performance RADIUS server.
Loaded: loaded (/usr/lib/systemd/system/radiusd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2022-06-23 09:13:53 PST; 9s ago
Process: 2900 ExecStart=/usr/sbin/radiusd -d /etc/raddb (code=exited, status=1/FAILURE)
Process: 2897 ExecStartPre=/usr/sbin/radiusd -C (code=exited, status=0/SUCCESS)
Process: 2891 ExecStartPre=/bin/sh /etc/raddb/certs/bootstrap (code=exited, status=0/SUCCESS)
Process: 2889 ExecStartPre=/bin/chown -R radiusd.radiusd /var/run/radiusd (code=exited, status=0/SUCCESS)
Main PID: 1789 (code=exited, status=0/SUCCESS)
Jun 23 09:13:53 FPM-FreeRad01.int.ahinet.ph systemd[1]: Starting FreeRADIUS high performance RADIUS server....
Jun 23 09:13:53 FPM-FreeRad01.int.ahinet.ph systemd[1]: radiusd.service: Control process exited, code=exited status=1
Jun 23 09:13:53 FPM-FreeRad01.int.ahinet.ph systemd[1]: radiusd.service: Failed with result 'exit-code'.
Jun 23 09:13:53 FPM-FreeRad01.int.ahinet.ph systemd[1]: Failed to start FreeRADIUS high performance RADIUS server..
I've been dealing with this since yesterday and I tried searching for other related problems but cannot find some answers so I try asking for help here. Any help would be appreciated.
Thank you

Why does /etc/mysql/debian-start give me this error when starting MariaDB on Linux Mint?

I am setting up multiple instances of MariaDB on Linux Mint 20.2. I have managed to get the first one set up, and it seems basically OK (I can connect to a database, and by querying the MariaDB variables, can verify that the socket, port etc. match what I put in the configuration file). However, I am getting a confusing error, not from the server process itself, but from the associated systemd script. This is what happens when I start the service and then check the status :
root#TMG-Toshiba:/var/local/mysql/toot# systemctl status mariadb#toot
● mariadb#toot.service - MariaDB 10.3.32 database server (multi-instance toot)
Loaded: loaded (/lib/systemd/system/mariadb#.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-12-07 18:35:11 GMT; 2s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 7776 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 7781 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITIONtoot (code=exited, status=0/SUCCESS)
Process: 7790 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery --defaults-file=/etc/mysql>
Process: 7881 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITIONtoot (code=exited, status=0/SUCCESS)
Process: 7883 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 7850 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 4137)
Memory: 85.9M
CGroup: /system.slice/system-mariadb.slice/mariadb#toot.service
└─7850 /usr/sbin/mysqld --defaults-file=/etc/mysql/conf.d/mytoot.cnf
Dec 07 18:35:11 TMG-Toshiba systemd[1]: Starting MariaDB 10.3.32 database server (multi-instance toot)...
Dec 07 18:35:11 TMG-Toshiba mysqld[7850]: 2021-12-07 18:35:11 0 [Note] /usr/sbin/mysqld (mysqld 10.3.32-MariaDB-0ubuntu0.20.04.1) starting as process 7850 ...
Dec 07 18:35:11 TMG-Toshiba systemd[1]: Started MariaDB 10.3.32 database server (multi-instance toot).
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7888]: Looking for 'mysql' as: /usr/bin/mysql
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7888]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7888]: Version check failed. Got the following error when calling the 'mysql' command line client
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7888]: ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (115)
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7888]: FATAL ERROR: Upgrade failed
Dec 07 18:35:12 TMG-Toshiba /etc/mysql/debian-start[7897]: Checking for insecure root accounts.
Dec 07 18:35:12 TMG-Toshiba debian-start[7900]: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Could it be that it is complaining about not being able to connect through a socket because I have specified "protocol = tcp" in the "client.cnf" section (I did this so I could just enter "mysql -P 3307 ..., mysql -P 3308" etc, instead of having to type in the socket path)? But in any case, should it be running that script anyway? The "debian-start" script is called by mariadb#.service, but if you look at the "debian-start" script itself, it actually contains this line:
NOTE: This file is read only by the traditional SysV init script, not systemd.
So should I just remove from mariadb#.service that call to debian-start?

Deploy Flask with Gunicorn and NginX Gunicorn Error "Failed with result 'exit-code'"

I'm following this YouTube Tutorial to setup my Server with Flask and Nginx: https://www.youtube.com/watch?v=o2WA-A67Bks&t=360s
Right now I'm at the Gunicorn part. I tried to start following commands:
systemctl daemon-reload
systemctl start index
systemctl enable index
systemctl status index
But it doesn't work. The Error Message looks like this:
● index.service - Gunicorn instance to serve One
Loaded: loaded (/etc/systemd/system/index.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-12-01 18:14:40 CET; 8s ago
Main PID: 24620 (code=exited, status=203/EXEC)
Dez 01 18:14:40 h2912959.stratoserver.net systemd[1]: Started Gunicorn instance to serve One.
Dez 01 18:14:40 h2912959.stratoserver.net systemd[24620]: index.service: Failed to execute command: No such file or directory
Dez 01 18:14:40 h2912959.stratoserver.net systemd[24620]: index.service: Failed at step EXEC spawning /var/www/html/myprojectenv/bin/gunicorn: No such file or directory
Dez 01 18:14:40 h2912959.stratoserver.net systemd[1]: index.service: Main process exited, code=exited, status=203/EXEC
Dez 01 18:14:40 h2912959.stratoserver.net systemd[1]: index.service: Failed with result 'exit-code'.
My index.service file looks like that:
[Unit]
Description=Gunicorn instance to serve One
After=network.target
[Service]
User=daemon
Group=www-data
WorkingDirectory=/var/www/html
Environment="PATH=/var/www/html/myprojectenv/bin"
ExecStart=/var/www/html/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
Can please help anyone?

OpenStack Keystone Identity Service Httpd Failed (rocky version)

Hello and thanks for taking some of your time to check my problem
i'm following the detailed steps by openstack to install openstack in no avail (https://docs.openstack.org/keystone/rocky/install/keystone-install-rdo.html)
I've tried to change the 5000 port for the service but the result is the same
any insights are most welcomed
[root#localhost i-openstack]# systemctl enable httpd.service
[root#localhost i-openstack]# systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root#localhost i-openstack]# journalctl -xe
Oct 08 05:12:39 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Oct 08 05:12:39 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Oct 08 05:12:39 localhost.localdomain systemd[1]: httpd.service failed.
Oct 08 05:12:39 localhost.localdomain polkitd[1824]: Unregistered Authentication Agent for unix-process:4229:106865 (system bus name :1.42, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Oct 08 05:27:21 localhost.localdomain polkitd[1824]: Registered Authentication Agent for unix-process:4930:195069 (system bus name :1.43 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale
Oct 08 05:27:21 localhost.localdomain systemd[1]: Reloading.
Oct 08 05:27:21 localhost.localdomain polkitd[1824]: Unregistered Authentication Agent for unix-process:4930:195069 (system bus name :1.43, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Oct 08 05:27:26 localhost.localdomain polkitd[1824]: Registered Authentication Agent for unix-process:4950:195568 (system bus name :1.44 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale
Oct 08 05:27:26 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Oct 08 05:27:26 localhost.localdomain httpd[4956]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:5000
Oct 08 05:27:26 localhost.localdomain httpd[4956]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:5000
Oct 08 05:27:26 localhost.localdomain httpd[4956]: no listening sockets available, shutting down
Oct 08 05:27:26 localhost.localdomain httpd[4956]: AH00015: Unable to open logs
Oct 08 05:27:26 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Oct 08 05:27:26 localhost.localdomain kill[4958]: kill: cannot find process ""
Oct 08 05:27:26 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Oct 08 05:27:26 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Oct 08 05:27:26 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Oct 08 05:27:26 localhost.localdomain systemd[1]: httpd.service failed.
Oct 08 05:27:26 localhost.localdomain polkitd[1824]: Unregistered Authentication Agent for unix-process:4950:195568 (system bus name :1.44, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Oct 08 05:34:01 localhost.localdomain polkitd[1824]: Registered Authentication Agent for unix-process:5222:235020 (system bus name :1.45 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale
Oct 08 05:34:01 localhost.localdomain systemd[1]: Reloading.
Oct 08 05:34:01 localhost.localdomain polkitd[1824]: Unregistered Authentication Agent for unix-process:5222:235020 (system bus name :1.45, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Oct 08 05:34:03 localhost.localdomain polkitd[1824]: Registered Authentication Agent for unix-process:5240:235248 (system bus name :1.46 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale
Oct 08 05:34:03 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
SOLUTION : It seemed i had to disable SELinux
Disable temporaliy
sudo setenforce 0
Restart httpd service
service httpd restart
Disable SELinux persistently (reboot required)
nano /etc/selinux/config
SELINUX=disabled

Cant start mariadb after switching Data Directory

Im trying to switch the data directory of mariadb to my HDD drive. But if i change datadir variable in the 50-server.cnf, mariadb wont start.
I have already modified the new directory with chmod and chown.
After switching the directory i get this message:
pi#raspberrypi:/etc/mysql/mariadb.conf.d $ sudo systemctl restart mariadb
Job for mariadb.service failed because the control process exited with error >code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
This is the Error:
● mariadb.service - MariaDB 10.1.38 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-08-10 13:10:25 CEST; 3min 26s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 5386 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 5309 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] &&
Process: 5305 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 5302 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 5386 (code=exited, status=1/FAILURE)
Status: "Starting Innodb crash recovery"
Aug 10 13:10:20 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
Aug 10 13:10:22 raspberrypi mysqld[5386]: 2019-08-10 13:10:22 1996119856 >[Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starti
Aug 10 13:10:25 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Aug 10 13:10:25 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
Aug 10 13:10:25 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
Aug 10 13:10:25 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.

Resources