Docfuntional

Documentation by Dysphunkional

MariaDB

This guide will show how to install MariaDB, a drop in replacement for MySQL in FreeBSD 9.x. For ease of management nginx and phpMyAdmin will be installed as well.
To get the FPM module to use PHP with nginx we have to install PHP from source. Install or update the ports collection first. We don’t want to have to compile all of the dependencies for PHP so we will install portmaster and use that to install PHP from source and portmaster will automatically install binaries for dependencies if they are up to date. Be sure to install or upgrade the ports collection and portmaster before you begin.

Install MariaDB

portmaster -P databases/mariadb55-server

Accept the Defaults for MariaDB and all dependancies.

Set MariaDB to start automatically

echo 'mysql_enable="YES"' >> /etc/rc.conf

Start MariaDB

/usr/local/etc/rc.d/mysql-server start

Set a root password for MariaDB

/usr/local/bin/mysqladmin -u root password 'your-password'

Install nginx

nginx is a web server that is faster and uses less resources than Apache.

portmaster -P www/nginx

Accept the Defaults for nginx and all dependancies.

Configure nginx

Edit /usr/local/etc/nginx/nginx.conf and add the following location blocks to the server block:

location /phpMyAdmin {
    root /usr/local/www/;
    index index.php index.html index.htm;
    location ~ ^/phpMyAdmin/(.+\.php)$ {
        try_files $uri =404;
        root /usr/local/www/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

location /phpmyadmin {
    rewrite ^/* /phpMyAdmin last;
}

Set nginx to start automatically

echo 'nginx_enable="YES"' >> /etc/rc.conf

Start nginx

/usr/local/etc/rc.d/nginx start

Install PHP

Install PHP with FPM

portmaster -P lang/php5

Check the box for FPM
PHP5 install options
Accept the defaults for any other programs that will be installed. portmaster will then build PHP and any dependancies that have newer versions in source than precompiled.
By default there is no php.ini file so make a copy of php.ini-production

cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Install PHP Extensions

To get phpMyAdmin working and able to talk to MariaDB we need to install a couple of extensions.

portmaster -P databases/php5-mysqli
portmaster -P databases/php5-mysql

Set php-fpm to start automatically

echo 'php_fpm_enable="YES"' >> /etc/rc.conf

Start php-fpm

/usr/local/etc/rc.d/php-fpm start

Install phpMyAdmin

portmaster -P databases/phpmyadmin

Accept the defaults for phpMyAdmin and all dependencies.

Configure phpMyAdmin

Edit the /usr/local/www/phpMyAdmin/config.inc.php file to look like this but using your own blowfish secret. You can generate a random blowfish secret by going to the online phpmyadmin blowfish secret generator

<?php
$cfg['blowfish_secret'] = '9L6BEZ8DavMnK)iXZSxW6VfIKHegcO]2bkkaoDy0';

/* Servers configuration */
$i = 0;

/* Server: localhost */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'http';

/* End of servers configuration */

$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;

?>

Log Into phpMyAdmin

Using your web browser go to http://IPAddress/phpMyAdmin/ and log in with your the username root and the password you set for MariaDB. If you don’t know the IP address of the jail running phpmyadmin you can run the ifconfig command from within the jail to find it.

ifconfig

Look in the output for the address after “inet”. My jail’s address is 10.1.0.222 in the example below:

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
        ether 08:00:27:97:f5:4b
        inet 10.1.0.222 netmask 0xffffff00 broadcast 10.1.0.255
        media: Ethernet autoselect (1000baseT )
        status: active
ipfw0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 65536
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: