>Setting up Apache2/mod_php/mod_ssl ….

> Excellent Guide: http://www.bsdguides.org/guides/freebsd/webserver/apache_ssl_php_mysql.php

Post Notes on Apache (2.0.50):

Since 2.0.49_2, to run apache www server from startup, add apache2_enable=”YES”

in your /etc/rc.conf.

Available variables you add/set to /etc/rc.conf.

– apache2_enable (bool): Set to “NO” by default.

Set it to “YES” to enable apache2.

– apache2ssl_enable (bool): Set to “NO” by default.

Set it to “YES” to start apache with SSL

(if exists in httpd.conf).

– apache2limits_enable (bool):Set to “NO” by default.

Set it to yes to run `limits $limits_args`

just before apache starts.

– apache2_flags (str): Set to “” by default.

Extra flags passed to start command.

– apache2limits_args (str): Default to “-e -C daemon”

Arguments of pre-start limits run.

Apache2 Installed OK and I added the following to /etc/rc.conf

### Start-up Options for Apache2 ############



Manually creating the directories for SSL if they do not already exists:

$> mkdir /usr/local/etc/apache2/ssl.key

$> mkdir /usr/local/etc/apache2/ssl.crt

$> chmod 0700 /usr/local/etc/apache2/ssl.key

$> chmod 0700 /usr/local/etc/apache2/ssl.crt

Installing MySQL (mysql-server-4.0.20)

$> cd /usr/ports/databases/mysql40-server

$> make install WITH_OPENSSL=yes distclean

Added group “mysql”.

Added user “mysql”.

# Personal Note: Remember to change the password for mysql user root.

Next I will install mod_php4 and mod_php5

Note: Make sure to check the OpenSSL box and leave the rest of the

default values alone.

$> cd /usr/ports/www/mod_php4

$> make install distclean

$> cd /usr/ports/lang/php4-extensions

$> make install distclean

I just realized that I can not install both mod_php4 and mod_php5 because of the following error:

===> mod_php5-5.0.0_2,1 conflicts with installed package(s):


They install files into the same place.

Please remove them first with pkg_delete(1).

*** Error code 1

Stop in /usr/ports/www/mod_php5.

*** Error code 1

Stop in /usr/ports/www/mod_php5.

So, for now I’ll just stick with mod_php4 and its extensions

$> cd /usr/ports/www/mod_php5

$> make install distclean

$> cd /usr/ports/lang/php5-extensions

$> make install distclean

Edit Apache’s configuration file after all the “LoadModule” lines:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Certificate Creation:


Change to root’s dir and issue the following:

$> mkdir SSLCertificates

$> cd SSLCertificates

$> opensll genrsa -des3 -out server.key 1024

From the above key we created we then need to make a certificate signing Request (CSR)

from the keys we just created.

$> openssl req -new -key server.key -out server.csr

After the above command use the same password used during CSR

Fill out all neccessary information required.

Now we need to sign our certificate

$> openssl x509 -req -days 365 -in server.csr signkey server.key -out server.crt

The above signs and makes our certificate valid for 365 days. Now the files need to be

copied to the appropiate directories.

$> cp server.key /usr/local/etc/apache2/ssl.key/

$> cp server.crt /usr/local/etc/apache2/ssl.crt/

$> chmod 0400 /usr/local/etc/apache2/ssl.key/server.key

$> chmod 0400 /usr/local/etc/apache2/ssl.key/server.crt

The following windows were open with these links before I rebooted!





This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s