2

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.

I've double and even triple-checked this post to confirm that my ec2 security group is configured correctly, which it is.

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. Does that matter?

Normally, I do my best to look through the error logs and just figure out the cause of the problem myself, but the only error I can identify anywhere is in /var/log/httpd/error_log, which reads:

AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

If this question has been asked before, please direct me to it. I've searched all over, with no luck thus far.

Cheers.

7
  • The error you posted said it could not start Apache as Apache was already running. Make sure there are no Apache processes running, then try to start the Apache service. It appears you are using systemd, so you would want to use systemctl start httpd to attempt to start the Apache service. The service and chkconfig commands are deprecated on a systemd machine and not used. Apr 7, 2018 at 19:36
  • @GracefulRestart okay. when trying to verify that there are no Apache process already running sudo systemctl status httpd, I was given the same output that I listed for systemctl status httpd.service. Running sudo systemctl start httpd directs me to examine systemctl status httpd.service for more information. What now?
    – nat5142
    Apr 7, 2018 at 19:59
  • You can run apachectl -t to check httpd config. What happens when you try start httpd with firewalld disabled?
    – Alxs
    Apr 7, 2018 at 22:54
  • @nat5142 if the error is still that there is an Apache process running, then you need to kill that process before you try to start Apache again. That running process is apparently not being handled by systemd, pgrep httpd to figure out what the running process ID is. Apr 8, 2018 at 0:41
  • @Alxs running apachectl -t doesn't output anything at all, actually. Any idea why that could be happening?
    – nat5142
    Apr 8, 2018 at 0:45

1 Answer 1

2

SOLUTION: thanks to @GracefulRestart, I was able to determine the issue:

I think my mistake was in using the same security group for multiple ec2 instances (each of which I had now deactivated). Anyway, I ran pgrep httpd, and saw a list of 7 numbers returned. Then ran ps -aux to view the full list of processes that I had running. At the bottom of that list were all of the httpd processes returned from pgrep httpd (most had a apache as user, but not all). I killed each of them using:

sudo kill -9 [PID]

Then ran sudo apachectl restart, and it worked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .