How to Start, Stop, and Restart Apache in Linux

Posted by Johan Cyprich on 12 Aug 2010 | Tagged as: How To

At various times, you will need to manually start and stop Apache. This could be due to making changes in the httpd.conf file which requires a restart, or the web server could be experiencing problems. You can perform these commands in a Linux terminal with httpd.

  1. To start Apache, type
    /etc/init.d/httpd start
  2. To stop Apache, type
    /etc/init.d/httpd stop
  3. To restart Apache, type
    /etc/init.d/httpd restart

Setting the ServerName

One problem that you may encounter when you start or restart Apache is that the domain name may not be defined. This can easily be fixed by opening the httpd.conf file in the /etc/init.d/conf/ folder and editing ServerName (it may have been commented out). See below for error:

Apache Error: can't determine ServerName.

Give a meaningful name to this variable and the warning will no longer be displayed when starting Apache (see below):

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn’t have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName webserver



Tweet This Tweet This Post!

Related posts:
    Setting Up URL Rewriting for Apache in Linux
    Display a List of Installed Modules in Apache
    How To Restart VNC on OS X
    Fixing PostgreSQL Services With Clean Install

Share this post:

del.icio.us:How to Start, Stop, and Restart Apache in Linux digg:How to Start, Stop, and Restart Apache in Linux spurl:How to Start, Stop, and Restart Apache in Linux wists:How to Start, Stop, and Restart Apache in Linux simpy:How to Start, Stop, and Restart Apache in Linux newsvine:How to Start, Stop, and Restart Apache in Linux blinklist:How to Start, Stop, and Restart Apache in Linux furl:How to Start, Stop, and Restart Apache in Linux reddit:How to Start, Stop, and Restart Apache in Linux fark:How to Start, Stop, and Restart Apache in Linux blogmarks:How to Start, Stop, and Restart Apache in Linux Y!:How to Start, Stop, and Restart Apache in Linux smarking:How to Start, Stop, and Restart Apache in Linux magnolia:How to Start, Stop, and Restart Apache in Linux segnalo:How to Start, Stop, and Restart Apache in Linux gifttagging:How to Start, Stop, and Restart Apache in Linux

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


One Response to “How to Start, Stop, and Restart Apache in Linux”

  1. on 17 Aug 2010 at 11:23 am 1.Setting Up URL Rewriting for Apache in Linux | cyprich.com said …

    [...] you made the changes, you’ll need to restart Apache. If your not sure how to do this, see How to Start, Stop, and Restart Apache in Linux.  Test mod_rewrite by loading the following files (.htaccess, one.html, two.html) on your web [...]

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv badge