How to install phpMyAdmin with HHVM, Nginx and MariaDB on an Ubuntu 14.04 VPS

phpmyadmin hhvmIn this tutorial we are going to provide you with step-by-step instructions on how to install phpMyAdmin with HHVM, Nginx and MariaDB on an Ubuntu 14.04 VPS. PhpMyAdmin is an open source application, written in PHP, intended to handle the administration of MySQL / MadiaDB databases over the intuitive web interface.


Make sure your package list and the OS packages are up to date by running the following commands:

apt-get update 
apt-get upgrade

Stop the Apache service and disable it to start on boot:

service apache2 stop
update-rc.d -f apache2 remove

Install and configure Nginx:

apt-get install python-software-properties software-properties-common
add-apt-repository ppa:nginx/stable
apt-get install nginx

Create a new nginx server block for your website:

vi /etc/nginx/sites-available/your-domain.com
server {
  server_name your-domain.com;
  listen 80;
  root /var/www/your-domain.com;
  access_log /var/www/your-domain.com/logs/access.log;
  error_log /var/www/your-domain.com/logs/error.log;
  index index.php;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ /\.ht {
    deny  all;
  }

  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Install HHVM
Create a new ‘hhvm.list’ file and add the HHVM source to it:

vi /etc/apt/sources.list.d/hhvm.list
deb http://dl.hhvm.com/ubuntu trusty main

Then, add the HHVM key and install the hhvm package:

wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
apt-get update
apt-get install hhvm
/usr/share/hhvm/install_fastcgi.sh
vi /etc/hhvm/php.ini
; php options
; session.save_handler = files
; session.save_path = /var/lib/hhvm/sessions
; session.gc_maxlifetime = 1440

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
vi /etc/hhvm/server.ini
; php options

pid = /var/run/hhvm/pid

; hhvm specific

hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc

Install MariaDB:

apt-get install mariadb-server

Run the following command:

mysql_secure_installation

Set your MariaDB ‘root’ user password (make sure to use a strong password utilizing at least 8 characters including alphanumeric and grammatical symbols), remove anonymous user accounts, then type ‘N’ if you like to enable root login remotely, and type ‘Y’ on the next two questions to remove the test database and access to it and reload privilege tables.

Install phpMyAdmin:

apt-get install phpmyadmin
ln -sf /usr/share/phpmyadmin/ /var/www/your-domain.com/

In order to access phpMyAdmin over SSL, create an SSL certificate or purchase a new SSL certificate here.

cd /etc/nginx/
openssl genrsa -des3 -out server.key 1024
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
chmod 400 server.key

Then, edit the Nginx configuration and create a new nginx server block:

vi /etc/nginx/sites-available/your-domain.com

Add these lines at the end of the file:

server {
         listen       443;
    ssl on;
    ssl_certificate /etc/nginx/server.crt;
    ssl_certificate_key /etc/nginx/server.key;

  server_name your-domain.com;
  root /var/www/your-domain.com;
  access_log /var/www/your-domain.com/logs/access.log;
  error_log /var/www/your-domain.com/logs/error.log;
  index index.php;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ /\.ht {
    deny  all;
  }

  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Run these commands:

ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/your-domain.com
rm /etc/nginx/sites-enabled/default
mkdir -p /var/www/your-domain.com/logs/
chown www-data: -R /var/www/your-domain.com/

Edit the ‘/usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php’, search for this line:

require_once './libraries/logging.lib.php';

and add the following line above it:

$GLOBALS['cfg']['Server']['port']=3306;

Restart HHVM, nginx and MariaDB services and configure them to start on boot:

service hhvm restart
service nginx restart
service mysql restart

update-rc.d nginx defaults
update-rc.d hhvm defaults
update-rc.d mysql defaults

Open https://your-domain.com/phpmyadmin , enter your MariaDB username and its password and start managing your MariaDB databases.

Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install phpMyAdmin with HHVM, Nginx and MariaDB for you. They are available 24×7 and will take care of your request immediately. Take a look at our managed HHVM hosting plans.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

2 thoughts on “How to install phpMyAdmin with HHVM, Nginx and MariaDB on an Ubuntu 14.04 VPS”

    • Our tutorial is tested and working without a problem. Have you made sure that you’ve followed the instructions correctly?
      Please try doing all of the described steps again and be more careful.

      Reply

Leave a Comment