Apache, PHP and MySQL on FreeBSD

Plain web server, with phpMyAdmin and SSL connections (https)
On FreeBSD 7.2
Lars Sommer, lasg@lasg.dk, 2009-05-20
DISCLAIMER: This is a personal note made for personal usage. It might not be easy usable nor explaining.

Apache:

Install this port:
www/apache22

Enable in /etc/rc.conf:
apache22_enable="YES"

Note from 090809: For future usage in systems with multiple web-users (vhosts), look at www/apache22-peruser-mpm instead!

---

MySQL:

Install this port:
databases/mysql50-server:

In /etc/rc.conf:
mysql_enable="YES"

/usr/local/etc/rc.d/mysql-server start
% mysqladmin -u root password 'mysecretpassword'

---

PHP:

Install this port:
lang/php5
With this option:
APACHE

Insert in httpd.conf:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
and index.php in the DirectoryIndex line

Install this port:
lang/php5-extensions
With this option:
MBSTRING
MCRYPT
MYSQL
GD

---

phpMyAdmin:

Install this port:
databases/phpmyadmin
With option MYSQLI

Initial config:
cp /usr/local/www/phpMyAdmin/libraries/config.default.php \ 
 /usr/local/www/phpMyAdmin/config.inc.php

Add:
$cfg['blowfish_secret'] = 'your_secret';
$cfg['Servers'][$i]['auth_type'] = 'cookie';

Add this to Apaches httpd.conf:
Alias /phpmyadmin/      "/usr/local/www/phpMyAdmin/"
<Directory "/usr/local/www/phpMyAdmin/">
        Options none
        AllowOverride Limit
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 10.6.6.
</Directory>

---

SSL for apache

Go to the folder where Apache expects the keys to be:
 cd /usr/local/etc/apache22/

Generate SSL keys, and set a simple passphrase (we'll remove it in a moment):
 openssl genrsa -des3 -out server.key 4096
 openssl req -new -key server.key -out server.csr
 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Remove the passphrase:
 cp server.key server.key.orig
 openssl rsa -in server.key.orig -out server.key

Remove junk:
 rm server.key.orig server.csr

Set nice permissions:
 chmod 0400 server.key
 chmod 0400 server.crt

Uncomment this in httpd.conf
 Include etc/apache22/extra/httpd-ssl.conf

Add this to /etc/rc.conf
apache22_flags="-DSSL"


Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *