How do I get Apache 2.0 to start with SSL enabled

| |

[phpwiki]
By default Apache 2.0 wraps the ssl server portion of it's configuration file in and directive. The IfDefined directive checks for values set by the -D command line option when apache was started. This means that "SSL" must be set on the command line when apache is started, otherwise the server will skip the ssl section of the configuration file and not listen on port 443.

The default way to start apache (or otherwise control apache) is with the apachectl command. This command is found in the directory $PREFIX/bin, where $PREFIX is the install prefix defined at compile time. When building from the source tarball, this is usually /usr/local/apache2/bin.
The syntax for the start command is:

apachectl start

While this doesn't take much to figure out, it can be confusing to set a define (or any other parameter) when using apachectl. Since the default syntax doesn't require anything more than a "start" or "stop" command, this is just a convenience. The correct syntax is really:

apachectl -k start

An this proper syntax is required when you give other arguments on the command line, like the -D for setting defines. So to start Apache with ssl enabled you need to give the command:

apachectl -D SSL -k start

If you ommit the -k (which one would assume from the convenience syntax above), then you'll get the usage error message from apache instead of a running apache.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Can also use sslstart as a shortcut

[phpwiki]
Looking in the apachectl file (it's a shell script) it shows that you can give sslstart, startssl, or start-SSL as a shortcut for the "-D SSL -k start" command line options. The simplified command for starting apache with ssl is:

apachectl startssl