
The httpd or command can be used to start, stop, and restart an Apache web server.
<web_server_root>/bin/httpd -k restart
<web_server_root>/bin/httpd -k start
<web_server_root>/bin/httpd -k stop
<web_server_root>/bin/httpd -k graceful
<web_server_root>/bin/httpd -k graceful-stop
The above command will use the <web_server_root>/conf/httpd.conf file. The -f option can be used to specify some other conf file, like this.
<web_server_root>/bin/httpd -k start -f conf/foo.conf
The -e option followed by a log level (such as debug) can be used to output additional details to the console and to the error_log.
<web_server_root>/bin/httpd -e debug -k restart
Likewise, you can use the -X flag to debug a web server instance.
]# <web_server_root> -k start -X
/opt/IBMIHS90/bin/httpd: line 96: 34966 Segmentation fault (core dumped) $HTTPD "$@"
The ps command can be used to determine if the web server is running. If the web server is running, the ps command should return processes associated with the web server. If the ps command fails to return any output, check the web server error_log.
When the ps command displays processes associated with the web server, you should be able to request resources from the web server. By default, the httpd.conf file has the following.
ServerName localhost:80
Listen 80
With this configuration, you should be able to enter the hostname of your web server in a browser and the following should be displayed.
Multiple web server
If you have two or more web servers on the same machine, you will have a unique conf file for each web server, like this.
<web_server_root>/conf/httpd1.conf
<web_server_root>/conf/httpd2.conf
The -f option can be used to target a specific web server. In this example, only the web server using httpd1.conf will be restarted.
<web_server_root>/bin/httpd -k restart -f <web_server_root>/conf/httpd1.conf
Did you find this article helpful?
If so, consider buying me a coffee over at