httpd/apachectl service fails to start on RHEL 7 - linux

I'm having some trouble launching my Apache server from RHEL 7 (Amazon ec2). My larger goal is to host a Flask application from the ec2 instance using an Anaconda environment, but right now I'm just concerned with getting the httpd service started properly.
I've found a number of similar questions posted here, here, here, etc., but none seem to address the exact problem I'm experiencing.
I'm following this tutorial down to the last > character, but the commands
sudo apachectl restart
and
sudo service httpd restart
both result in errors and direct me to examine systemctl status httpd.service for more information. The output of that file is as follows:
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-04-06 21:00:42 UTC; 4s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 32166 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 32165 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
Main PID: 32165 (code=exited, status=0/SUCCESS)
[long ec2 ip address] systemd[1]: Starting The Apache HTTP Server...
[long ec2 ip address] httpd[32165]: httpd (pid 28220) already running
[long ec2 ip address] kill[32166]: kill: cannot find process ""
[long ec2 ip address] systemd[1]: httpd.service: control process exited, code=exited status=1
[long ec2 ip address] systemd[1]: Failed to start The Apache HTTP Server.
[long ec2 ip address] systemd[1]: Unit httpd.service entered failed state.
[long ec2 ip address] systemd[1]: httpd.service failed.
The output of journalctl -xe returns the same.
Some information about my system (don't know whether or not any of this will be helpful, but I figured it would be best to include it):
Apache Version: Apache/2.4.6 (Red Hat Enterprise Linux) configured
$ /usr/bin/python -V
Python 2.7.5
$ sudo yum install mod_wsgi
Package mod_wsgi-3.4-12.el7_0.x86_64 already installed and latest version
$ service httpd configtest
Syntax OK
$ sudo chkconfig --levels 235 httpd on
Note: Forwarding request to 'systemctl enable httpd.service'
The command sudo netstat -lnp | grep :80 returns tcp 0 0 :::0 :::* LISTEN 28220/httpd
I am now noticing that the file /etc/init.d/httpd does not exist.
Anybody have a hint? If this question has been asked before, please direct me to it. I've searched all over, with no luck thus far.
Cheers.

Try killing the old pid. Looks like something is still running under httpd. Try doing a ps -ef | grep httpd to see what is running and kill it using sudo kill -9 processid (e.g. sudo kill -9 13254).

Related

Request timeout when pinging aws Linux instance

So i m trying to install a jenkins server on the free instance provided by aws, so I can test things out, problem is that I can connect via ssh using putty to the public ip and my key, but when I try to access the jenkins portal using the public DNS address and the port a timeout is returned
Also if i try to ping the machine from my laptop it returns "Request time out" every time.
Also jenkins server seems to be running and active:
[ec2-user#ip-1235 ~]$ sudo systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since Mon 2021-11-22 16:14:42 UTC; 7min ago
Docs: man:systemd-sysv-generator(8)
Process: 3693 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jenkins.service
└─3697 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_H...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal systemd[1]: Start...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal jenkins[3693]: St...
Nov 22 16:14:42 ip-1234.us-east-2.compute.internal systemd[1]: Start...
Hint: Some lines were ellipsized, use -l to show in full.

How to have systemd start Tomcat on port 80?

As described here and here, I'm trying (on Ubuntu 16.04) to start Tomcat 9.0.2 on port 80, by having systemd pre-initialize a socket on that privileged port and then pass it to Tomcat which runs as non-privileged user "tomcat" (I know there are other solutions, but I'm interested in making this one work). For this, I have the following socket unit (the "port" setting was already changed to 80 on server.xml):
/etc/sytemd/system/tomcat.socket
[Unit]
Description=Tomcat server socket
[Socket]
ListenStream=80
And the following service unit:
/etc/sytemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=CATALINA_PID=/opt/tomcat/9.0.2/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat/9.0.2
ExecStart=/opt/tomcat/9.0.2/bin/startup.sh
ExecStop=/opt/tomcat/9.0.2/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
[Install]
Requires=tomcat.socket
When running sudo systemctl start tomcat.service, the command outputs no error message, but then systemctl status tomcat.service displays a failed status:
tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; static; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-12-19 21:46:53 -05; 45min ago
Process: 10207 ExecStop=/opt/tomcat/9.0.2/bin/shutdown.sh (code=exited, status=1/FAILURE)
Process: 10175 ExecStart=/opt/tomcat/9.0.2/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 10189 (code=exited, status=0/SUCCESS)
As can be seen in the journald logs below, Tomcat does start, but shutdown.sh is immediately run and makes it exit. Apparently, Tomcat still tries to create a socket on port 80, which fails because user tomcat is not superuser, and proceeds to exit right away.
systemd[1]: Starting Apache Tomcat Web Application Container...
startup.sh[10175]: Existing PID file found during start.
startup.sh[10175]: Removing/clearing stale PID file.
startup.sh[10175]: Tomcat started.
systemd[1]: Started Apache Tomcat Web Application Container.
sudo[10172]: pam_unix(sudo:session): session closed for user root
shutdown.sh[10207]: PID file found but no matching process was found. Stop aborted.
systemd[1]: tomcat.service: Control process exited, code=exited status=1
systemd[1]: tomcat.service: Unit entered failed state.
systemd[1]: tomcat.service: Failed with result 'exit-code'.
If Tomcat 9 is capable of receiving a preinitialized socket from systemd, how can I make that work? Or is Tomcat unable to do so?

cant connect to Datastax OpsCenter after brand new install

Can anyone help, I did a fresh install of Datastax OpsCenter/Lifecylce Manager, installed via apg-get on clean Ubuntu VMs. But, I can not connect via browser, "site not found", on port 8888.
ps returns a running process and Status seems started. Any ideas?
root#unigmadevdse1:/var/log/opscenter# ps -ef | grep opscenter root
19381 1890 0 20:49 pts/0 00:00:00 grep --color=auto opscenter
root#unigmadevdse1:/var/log/opscenter# service opscenterd status ●
opscenterd.service - LSB: Cassandra cluster manager Loaded: loaded
(/etc/init.d/opscenterd; bad; vendor preset: enabled) Active:
active (exited) since Tue 2017-03-07 20:39:54 UTC; 9min ago
Docs: man:systemd-sysv-generator(8) Process: 18848 ExecStart=/etc/init.d/opscenterd start (code=exited, status=0/SUCCESS)
Mar 07 20:39:53 unigmadevdse1.unigmagroup.com systemd[1]: Starting
LSB: Cassandra cluster manager...
Mar 07 20:39:54 unigmadevdse1.unigmagroup.com systemd[1]: Started LSB: >Cassandra cluster manager.
Have a look in the opscenter.log file for any error messages [if you are not sure, run a find / -iname opscenter.log
or try a service opscenter start -f [will output to screen]

Unable to start postgresql service on CentOS 7

Unable to start postgresql-9.5 on CentOS 7.
I followed this page - https://wiki.postgresql.org/wiki/YUM_Installation - for installing the database server on CentOS.
I tried the same after setting setenforce 0, and that did not help either.
I am doing all operations as root.
systemctl start postgresql-9.5.service
Job for postgresql-9.5.service failed because the control process exited with error
code. See "systemctl status postgresql-9.5.service" and "journalctl -xe" for details.
And here is what I get for status -
Redirecting to /bin/systemctl status postgresql-9.5.service
● postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2016-02-18 15:20:30 EST; 2min 28s ago
Process: 15041 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
Feb 18 15:20:30 myserver systemd[1]: Starting PostgreSQL 9.5 database server...
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1
Feb 18 15:20:30 myserver systemd[1]: Failed to start PostgreSQL 9.5 database server.
Feb 18 15:20:30 myserver systemd[1]: Unit postgresql-9.5.service entered failed state.
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service failed.
And the contents of the different conf files are as follows -
[root#myserver /]# cat /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /usr/lib/tmpfiles.d/postgresql-9.5.conf
d /var/run/postgresql 0755 postgres postgres -
[root#myserver /]# cat /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /etc/alternatives/pgsql-ld-conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /var/lib/alternatives/pgsql-ld-conf
auto
/etc/ld.so.conf.d/postgresql-pgdg-libs.conf
/usr/pgsql-9.5/share/postgresql-9.5-libs.conf
950
Googled for the error that I am seeing.
A number of folks have seen the same error, and the underlying cause is different in each case. Reading through those posts, it is not clear that I am seeing any of the already reported causes.
Make sure you have installed all packages correctly and updated yum repository sections [base] and [updates] before installation as it mentioned in the guide . We have CentOS 7 with PostgreSQL 9.5 and it works perfectly fine with following steps:
vi /etc/yum.repos.d/CentOS-Base.repo
yum localinstall http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum list postgres*
yum install -y postgresql95-server.x86_64 postgresql95-contrib.x86_64 postgresql95-libs.x86_64
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5.service
systemctl start postgresql-9.5.service
and finally, systemctl status postgresql-9.5.service should show you something like this:
postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled)
Active: active (running) since Fri 2016-02-19 00:01:13 UTC; 6min ago
Process: 10809 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
Process: 10802 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 10811 (postgres)
CGroup: /system.slice/postgresql-9.5.service
├─10811 /usr/pgsql-9.5/bin/postgres -D /var/lib/pgsql/9.5/data
├─10812 postgres: logger process
├─10814 postgres: checkpointer process
├─10815 postgres: writer process
├─10816 postgres: wal writer process
├─10817 postgres: autovacuum launcher process
└─10818 postgres: stats collector process
The most common issue is that the database cluster was not initialized. You can initialize it easily by running the postgresql-XX-setup script with the initdb command, e.g.
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
Then start the Postgres service, e.g.
sudo systemctl start postgresql-11
These steps helped me on our test server.
Connect your server via SSH.
Then switch user:
sudo su - postgres
Check Postgres status:
pg_ctl status
Stop DB:
pg_ctl stop
Check if no server processes exist:
ps axf | grep postg
Start Postgres service:
sudo systemctl start postgresql.service
OR
sudo systemctl start postgresql
Then check status:
systemctl status postgresql.service ИЛИ systemctl status postgresql

Cannot connect to nginx server on fedora linux (digitalocean)

I tried to set up nginx on a brand new fedora box on DigitalOcean. These are my steps
$ yum install nginx
$ systemctl enable nginx
$ systemctl restart nginx
However, it doesn't seem to work. I get the following output when running systemctl status nginx
[root#inspiredev ~]# systemctl status nginx -l
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
Active: active (running) since Fri 2014-11-07 14:26:33 EST; 1s ago
Process: 958 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
Process: 967 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 966 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 970 (nginx)
CGroup: /system.slice/nginx.service
├─970 nginx: master process /usr/sbin/ngin
└─971 nginx: worker proces
Nov 07 14:26:33 inspiredev systemd[1]: Starting The nginx HTTP and reverse proxy server...
Nov 07 14:26:33 inspiredev nginx[966]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Nov 07 14:26:33 inspiredev nginx[966]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Nov 07 14:26:33 inspiredev systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Nov 07 14:26:33 inspiredev systemd[1]: Started The nginx HTTP and reverse proxy server.
I can't seem to figure out or where I went wrong. It'd be great if someone can help with this.
EDIT: When I go to the box's IP address, I got nothing, which is why I feel like something is not working right.
From the systemd logs, nginx service appears to be running. (the warning about the pid file not found seems endemic to many distributions).
On fedora 19/20 (systemd based), open the firewall with the following commands:
firewall-cmd --permanent --zone=public --add-service=http
systemctl restart firewalld.service
or alternatively:
firewall-cmd --permanent --zone=public --add-port=80/tcp
systemctl restart firewalld.service
The second version syntax lets you open any port/protocol combination.

Resources