How to start httpd/apache in foreground?

In this article we will discuss how to start Httpd/Apache in foreground.

How to start httpd/apache in foreground?

You can start httpd/apache with option -DFOREGROUND

Example :

1 2 3   /usr/sbin/httpd DFOREGROUND  

This command will pick the configuration from default configuration directories. Also, this “DFOREGROUND” flag ensure apache parent will run in the foreground and not detach from the shell.

One of the main uses of this method is to get apache to log to the console in the foreground. We can see the debug logs in the console itself, no need to tail the apache log files.

Also, when you run  apache/httpd server on Docker, using “docker exec” or  “docker cmd” , it is necessary to start httpd/apache in foreground. If you run it as daemon  Docker will exit thinking the job has finished.

If you enable debug logs in the startup, server will show debug logs in the console. please see below

1 2 3 4 5 6 7 8 9   [root@test.test.com~]# /usr/sbin/httpd -DFOREGROUND -e debug [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module auth_basic_module [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module auth_digest_module [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module authn_file_module [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module authn_alias_module [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module authn_anon_module [Thu Feb 16 20:12:45 2017] [debug] mod_so.c(246): loaded module authn_dbm_module  

 

Author: , 0000-00-00