Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

How to Start, Stop, and Restart Apache in Linux

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

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

  1. Pingback: Setting Up URL Rewriting for Apache in Linux | cyprich.com

Leave a Reply

Your email address will not be published. Required fields are marked *