Hack 76. Pass different httpd.conf filename to apachectl

by Ramesh

Typically you’ll modify the original httpd.conf to try out different Apache directives. If something doesn’t work out, you’ll revert back the changes. Instead of playing around with the original httpd.conf, copy it to a new httpd.conf.debug and use this new httpd.conf.debug file with Apache for testing purpose as shown below using option -f.

  1. # apachectl -f conf/httpd.conf.debug
  2.  
  3. # httpd -k start -f conf/httpd.conf.debug
  4.  
  5. [Note: you can use either apachectl or httpd as shown above]
  6.  
  7. # ps -ef | grep http
  8. root 25080 1 0 23:26 00:00:00 /usr/sbin/httpd -f conf/httpd.conf.debug
  9. apache 25099 25080 0 23:28 00:00:00 /usr/sbin/httpd -f conf/httpd.conf.debug
  10.  
  11. [Note: ps shows the httpd running with httpd.conf.debug file]

Once you are satisfied with the changes and Apache runs without any problem with httpd.conf.debug, you can copy the changes to httpd.conf and start the Apache normally as shown below.

  1. # cp httpd.conf.debug httpd.conf
  2.  
  3. # apachectl stop
  4.  
  5. # apachectl start
  6.  
  7. # ps -ef | grep httpd
  8. root 25114 1 0 23:28 00:00:00 /usr/sbin/httpd -k start
  9. daemon 25115 25114 0 23:28 00:00:00 /usr/sbin/httpd -k start
  10.  
  11. [Note: ps indicates that the httpd is running using the default config file]