How to restart apache Under Linux

Every time you make config changes to Apache, you have to restart the server. If you’re suffering the death of a thousand clicks trying to use a GUI to do this simple task, here’s a tip that’ll get it done quick and easy.

If you’
re like me (read: not a seasoned sysadmin) you’

ve probably taken the GUI root to restarting Apache. Whether weaving through the RedHat Control Panel or by simply closing your Windows DOS window, you may have thought “There’
s got to be a better way!”

Well, there is.

Restarting Apache Under Linux

OK, here are the magic one-liners for your hungry command line:

Restart:


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

Start:


httpd

(See the Apache Documentation for all the command line flags.)

Stop:


kill -TERM `cat /usr/local/apache/logs/httpd.pid`

(See the Apache Documentation for more options.)

Restarting Apache Under Windows

Well if you insist upon using a non-open OS with this open sever, OK. I’

ll assume you’
re running Apache under NT, and that you’
ve set it up as a service. Instead of futzing with the Services window, these one-liners can save you time by entering them in the RUN menu or from a DOS prompt.

Start:


NET START APACHE

Stop:


NET STOP APACHE

If you need to set up Apache as a service under NT, check out the Apache Windows Documentation. If you’

re running Windows 95/98, you can restart or stop it by opening up a DOS window and issuing the following commands.

Restart:


apache -k restart

Stop:


apache -k shutdown

More information on Windows commands and configs are available in Apache’
s Windows Documentation
.

Leave a Reply