Multiple directives in apache2 / httpd via command line?

1

I know you can specify one directive at the command line using this syntax:

httpd -c "DocumentRoot ." 

But what if I also want to specify other options? Is this possible?

I know there are static switches like -p, -d etc. but I really want to launch a http daemon without any conf file so want the ability to specify all configuration in the command itself.

Don't question me on why I prefer this, that's beyond the scope of the question. I just want to launch a bunch of daemons by copying and pasting a single command. I tried with a here document but I'm hoping there's a more direct approach. I also do not want to use a different binary like lighttpd. I want the industry standard capability of the latest version of Apache.

EDIT - I tried this and it's still trying to use port 80:

httpd     -c "DocumentRoot ."     -c 'Listen 7000' 

Sridhar Sarnobat

Posted 2014-07-05T05:41:09.150

Reputation: 870

Answers

0

It seems that older versions of Apache don't support multiple '-c' options - such as httpd on Mac OS Lion. But it's fine on Ubuntu 12.04:

apache2 \
    -f /dev/null \
    -C "DocumentRoot $PWD" \
    -C 'Listen 7000' \
    -C 'PidFile /tmp/pidfile' \
    -C 'ErrorLog /dev/stdout' \
    -D FOREGROUND

Credits: https://gist.github.com/thwarted/7672130

Sridhar Sarnobat

Posted 2014-07-05T05:41:09.150

Reputation: 870