User login

Restarting Apache the safe way: test first (ironically, discovered accidentally)

Even in GNU-Linux, don't believe everything you read.

ben@agaric:/etc/apache2/sites-available$ sudo a2ensite mediademocracyday.org
Site mediademocracyday.org installed; run /etc/init.d/apache2 reload to enable.
ben@agaric:/etc/apache2/sites-available$ vi agaricdesign
ben@agaric:/etc/apache2/sites-available$ /etc/init.d/apache2 reload
Reloading web server config...8162
httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
failed!

Hmm, I take that back about GNU Linux. It does not lie. Actually, maybe I (brilliantly) did this "To check the semantics of the configuration files as well as the syntax, you can try starting httpd as a non-root user."

From http://httpd.apache.org/docs/1.3/stopping.html and in http://httpd.apache.org/docs/2.2/stopping.html

Note: If your configuration file has errors in it when you issue a restart then your parent will not restart, it will exit with an error. In the case of graceful restarts it will also leave children running when it exits. (These are the children which are "gracefully exiting" by handling their last request.) This will cause problems if you attempt to restart the server -- it will not be able to bind to its listening ports. Before doing a restart, you can check the syntax of the configuration files with the -t command line argument (see httpd ). This still will not guarantee that the server will restart correctly. To check the semantics of the configuration files as well as the syntax, you can try starting httpd as a non-root user. If there are no errors it will attempt to open its sockets and logs and fail because it's not root (or because the currently running httpd already has those ports bound). If it fails for any other reason then it's probably a config file error and the error should be fixed before issuing the graceful restart.

so let's do it:

ben@agaric:/etc/apache2/sites-available$ sudo /etc/init.d/apache2 reload
Reloading web server config...8162
.
ben@agaric:/etc/apache2/sites-available$

Resolution

Comments

Just the facts:

/etc/init.d/apache2 reload
and
sudo /usr/sbin/apache2ctl -t

to test, followed by either:
sudo /usr/sbin/apache2ctl graceful
or
sudo /etc/init.d/apache2 reload

Seems to work pretty safely.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.