Amazon EC2 - Apache server restart issue

前端 未结 4 692
故里飘歌
故里飘歌 2021-02-04 09:41

When i run this command

sudo /etc/init.d/httpd restart

it gives below error

Stopping httpd: [FAILED]

4条回答
  •  别那么骄傲
    2021-02-04 10:28

    I ran into this problem when I installed apache from source, but then tried to run

    $ sudo /etc/init.d/httpd restart 
    

    which was using a pre-installed version of apache. The stop directive in /etc/init.d/httpd was not removing the httpd.pid file that was created when starting the source-installed version of apache.

    To determine if this is also the reason for your problem, find where the httpd.pid file is getting set when you run

    $ sudo apachectl start
    

    If you installed from source and apache2 is living in /usr/local/apache2, then the httpd.pid file should get created in /usr/local/apache2/logs. When you stop apache by running

    $ sudo apachectl stop
    

    this file should get removed. So to test if the httpd.pid file is causing your problem, start apache by calling

    $ sudo apachectl start
    

    and locate the httpd.pid file. Then try stopping apache by using

    $ sudo /etc/init.d/httpd stop
    

    If the original httpd.pid file is still present, then that is why apache is unable to start when you use

    $ sudo /etc/init.d/httpd start
    

    To get my /etc/init.d/httpd file to work correctly, I explicitly put the call to apachectl in the start and stop methods:

    #!/bin/bash
    # /etc/init.d/httpd
    #
    # Path to the apachectl script, server binary, and short-form for messages. 
    apachectl=/usr/local/apache2/bin/apachectl 
    httpd=/usr/local/apache2/bin/httpd 
    pid=/usr/local/apache2/logs/httpd.pid 
    prog=httpd 
    RETVAL=0
    
    start() {
        echo -n $"Starting $prog: "
        $apachectl -k start
        RETVAL=$?
        echo
        return $RETVAL
    }
    stop() {
        echo -n $"Stopping $prog: "
        $apachectl -k stop
        RETVAL=$?
        echo
    }
    

提交回复
热议问题