Apache
Apache Feather.
Image courtesy Apache Software Foundation
httpd.conf
file or another configuration file (like adding a new virtual host),
you will need to restart Apache so that your changes will take effect.
Luckily, this is very easy to do.Difficulty: Easy
Time Required: 1 minute
To restart your Linux Apache web server, the best way is to use the
init.d command. This command is available on many distributions of Linux including Red Hat, Ubuntu, and Gentoo.- Login to your web server using SSH or telnet and make sure that your system includes the
init.dcommand. It is usually found in the/etcdirectory, so list that directory:ls /etc/i* - If your server uses
init.dyou will get a listing of the initialization files in that folder. Look forapacheorapache2in that folder. If you haveinit.dbut do not have an Apache initialization file, go to the next section “Restarting Your Server Without Init.d” - If you have
init.dand an Apache initialization file then you can restart Apache using this command:
You may need to sudo in as the root user to run this command./etc/init.d/apache2 reload
reload
option is the best way to restart your Apache server, as it keeps the
server running (the process isn't killed and restarted). Instead it just
reloads the httpd.conf file. Which is usually all you want.If that doesn't work, you can also use the following commands instead:
/etc/init.d/apache2 restartkills the server process and then restarts it/etc/init.d/apache2 stopkills the server process
/etc/init.d/apache2 startstarts the server (and will throw an error message if the server is already running)
Restarting Your Server Without Init.d
If your server doesn't haveinit.d, don't despair, you can still restart your server. You just have to do it manually with the command apachectl.- Login to your web server machine using SSH or telnet
- Run the apache control program:
You may need to sudo in as the root user to run this commandapachectl graceful
apachectl graceful
command tells Apache that you want to restart the server gracefully
without aborting any open connections. It automatically checks the
configuration files before initiating the restart to make sure Apache
doesn't die.If
apachectl graceful doesn't restart your server, there are a few other things you can try.apachectl restartto restart the server. If the server is not running it is started. This command also runs a configuration test to make sure Apache won't die when it restarts.apachectl stopto stop the Apache serverapachectl startto start the Apache server (will throw an error message if Apache is running)apachectl configtestto test the configuration file syntax.
Tips for Restarting Your Apache Server:
init.d reloadandapachectl gracefulboth reload the configuration files and gracefully restart the web server. Any current connections are allowed to complete.init.d restartandapachectl restartreloads the configuration files and restarts. Any current connections are terminated immediately.- If the server isn't running, these commands will start it up.
- If neither of these commands work, you should turn off your Apache server (taking it down for a short time) with the
init.d stoporapachectl stopcommand, wait at least 10 seconds and then run theinit.d startstartapachectl start - If
that doesn't work, you should run a check on your configuration files
to make sure there isn't a problem with them by running
apachectl graceful
Comments
Post a Comment