Do more with Apache via the Command Line!

The command line utility httpd (some debian based distros based use the apache command instead of the httpd command)160px-asf-logosvg is just used to stop/start/reload the Apache server daemon. But there is more to httpd than this. We present you with some command-line options that enable you to change and test your apache configuration without manually editing the httpd.conf file.Read on..

Start up Apache using an alternative DocumentRoot:

This is useful if you’re trying out alternative versions of your web site, as it avoids editing the DocumentRoot option. Using the -c (Small C) option will overwrite your apache configuration file, whereas -C (Capital C) option will process the directive before the config files thus preventing the config file getting over-written.

sudo httpd -k start -c DocumentRoot /var/www/html_debug/”

Start up Apache using an alternative config file:

sudo httpd -k start -f conf/new-config.conf

Start up Apache using an some particular new module / test module: This command can be used to test some particular module before incorporating them full time into the httpd config file. For this, say you are testing a module mod1 then your new module mod1 will load only if the module mod1 is defined in the config file as:

<IfDefine loadmodule>

LoadModule mod1

<IfDefine>

sudo httpd -D mod1

After you’re done with any of these, issuing the following commands will restart the apache webserver with your normal settings / httpd configuration:

sudo httpd -k stop; sudo apachectl start


If this sounds like your situation, let's talk

No pitch decks. No sales process. Just a conversation about what you're dealing with and whether I can help.

Book a 30-minute call →