July 29, 2014

How to Install phpMyAdmin on FreeBSD

phpMyAdmin Logo

Now you can handle the administration of MySQL over the Web and on FreeBSD. It can manage a whole MySQL server as well as a single database. With phpMyAdmin you can easily browse through databases and tables, create, copy, rename, alter and drop databases and tables and many more.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Install phpMyAdmin

Install phpMyAdmin from your ports directory. I have choosen the default configuartion without X11 and OpenSSL.

cd /usr/ports/databases/phpmyadmin
make install clean; rehash

Configure phpMyAdmin for Nginx

This is an example server block for your Nginx configuartion file (nginx.conf).

server {
        listen 81;
        server_name localhost;
        location / {
            root /usr/local/www/phpMyAdmin;
            index index.php index.html index.htm;
        }
        location ~ \.php$ {
            root /usr/local/www/phpMyAdmin;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~ /\.ht {
            deny all;
        }
}