The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Proper way to restart apache via SSH? (and therefore root cron)

Discussion in 'EasyApache' started by Ishware, Sep 27, 2009.

  1. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    My search-fu has failed, so I'm asking after searching...

    In the past, I have successfully restarted apache using "service httpd restart", which caused output indicating the service was stopping, then starting.

    Currently, running that command gives no output, but pretty much instantly shows another command prompt. Same with "/use/local/apache/bin/apachectl restart"

    What's the proper way to restart apache? And in case it makes a difference - I'm planning to add this to root's cron (Apache causes high load after about 5-6 days, so I'm planning on restarting it daily - at 4:04 am, which I thought was clever ;-) )
     
  2. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    You can use either of the commands you listed as long as your login shell is configured correctly.

    Another way to do this that is not so picky about your environment:

    Code:
    # /etc/rc.d/init.d/httpd restart
    # /etc/rc.d/init.d/httpd status
    
     
  3. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    Another way to skin the same cat:

    /scripts/restartsrv_apache

    works on cPanel servers of any flavor/distro.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    To elaborate, this command is safer for novice administrators since it ensures that all Apache services (including HTTPS) come back online.
     
  5. Ishware

    Ishware Well-Known Member

    Joined:
    Nov 7, 2003
    Messages:
    168
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Panama City, FL
    cPanel Access Level:
    Root Administrator
    Awesome - thanks for the answers! :D
     
  6. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    This is simply due to the incredibly fast Apache restart that occurs on CPanel servers. I am not sure why exactly it occurs so fast but I love it compared to other servers such as Ensim/Parallels Pro which take forever.

    Anyone want to explain how the httpd restart works so fast on CPanel?
     
  7. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    The different is whether you are doing a full shutdown and startup of the server or a quick restart.

    The former, the order is given to stop the server and it waits till there is a safe point with no critical action and then shuts down. A second process brings the server back up again.

    In the later mentioned above, the main core stays online and the controlling process id is quick killed and restarted (HUP) which gives you very near instantaneous restart of a given server process.

    /etc/rc.d/init.d/httpd restart
     
  8. bvierra

    bvierra Well-Known Member

    Joined:
    Jul 28, 2006
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Southern California
    you really need to make sure you use:
    Code:
    /scripts/restartsrv_apache
    as it properly sets the ulimits before it starts apache. This becomes a big issue with lots of sites on a server or sites with large traffic volumes.
     
Loading...

Share This Page