There are mainly three kinds of ways to start/restart an Apache Server for different Linux distributions.
Taking
start as a quick example, they are:
Shell>> /usr/local/apache2/bin/apachectl -k start (Red Hat)
Shell>> /usr/local/apache2/bin/httpd -k start (when you don't have apachectl in Red Hat)
Shell>> /etc/init.d/apache2 start (Ubuntu, Debian, SUSE)
NOTE: The path of
apachectl and
httpd may differ from "/usr/local/apache2/bin/" depending on your installations and in some cases you don't even have to specify the patch.
I. Use of apachectl (Red Head)
Basically, it is easy to start/restart/stop an Apache web server by the commands
Shell>> apachectl -k start
Shell>> apachectl -k restart
Shell>> apachectl -k stop
to start, restart, stop your Apache server, respectively. Note you may need to specify the path to the apachectl command. For example, you may use
Full path:
Shell>> /usr/local/apache2/bin/apachectl -k restart
or
Relative path:
Shell>> bin/apachectl -k restart (when the console is in /usr/local/apache2/ in this case)
for restarting Apache.
Also, it is recommeded to use the parameter "graceful" to stop the sever after finishing serving all the HTTP requests while attempting the restart the sever. That is, we use
Shell>> apachectl -k graceful
to restart the Apache server.
You may also note that in SUSE Linux, you can restart (or start) the server by the command:
Shell> /etc/init.d/apache2 restart
II. Use of httpd
However, due to different versions of installation, sometimes
apachectl simply doesn't work. Instead, you may use the command
httpd (with a shell path specified). You may use
Shell>> ./bin/httpd -k restart
or
Shell>> ./bin/httpd -k graceful
to restart your Apache http daemon service.
III. Use of apache2 (Ubuntu, Debian, SUSE)
Shell> /etc/init.d/apach2 start|restart|stop
You may use the following command for restarting in Ubuntu:
Shell> sudo /etc/init.d/apach2 start/restart/stop
The Apache Official Documents for
1.
Stopping and Restarting
2.
apachectl - Apache HTTP Server Control Interface
3.
httpd - Apache Hypertext Transfer Protocol Server
Edited 9 time(s). Last edit at 11/03/2009 07:30PM by HP.
(
編輯記錄)