How to install MyBB on a LEMP (Linux + Nginx + MySQL + PHP-FPM) VPS

MyBB VPSMyBB, also known as MyBBoard or MyBulletinBoard, is very popular and free forum software developed using PHP and MySQL. This tutorial will help you install MyBB on a Linux virtual server.
This article assumes that Nginx is already set up and running with PHP 5.1 or newer via FastCGI. Also, MyBB forum requires a database for data storage, so you need to have MySQL, PostgreSQL, or SQLite installed and running on your VPS.

* Please refer to the following article about how to set up a LEMP server.

Let’s start with the installation procedure. Go to MyBB’s official website and download the latest version of their forum software:

wget http://www.mybb.com/download/latest

Extract the downloaded zip file to the Document Root directory of your website:

unzip mybb*.zip -d /var/www/html/mybb/
mv /var/www/html/mybb/Upload/* /var/www/html/mybb/

Change the ownership and set the required permissions to the following files and directories:

chown nginx -R /var/www/html/mybb/
mv /var/www/html/mybb/inc/config.default.php /var/www/html/mybb/inc/config.php
chmod +w /var/www/html/mybb/inc/settings.php

MyBB requires a MySQL user and database, so create them by executing the following commands:

mysql -u root -p
CREATE DATABASE mybbdb;
CREATE USER 'mybbuser'@'localhost' IDENTIFIED BY 'your-password-here';
GRANT ALL PRIVILEGES ON mybbdb.* TO 'mybbuser'@'localhost';
FLUSH PRIVILEGES;

Also, you need to create a new virtual host in Nginx, for example:

server {
    listen       80;
    server_name your-domain.com;
    access_log logs/your-domain.com_access.log;
    error_log logs/your-domain.com_error.log;
    root /var/www/html/mybb;
    location / {
    server_tokens off;
    index index.html index.htm index.php;
    rewrite ^/forum-([0-9]+)\.html$ /forumdisplay.php?fid=$1;
    rewrite ^/forum-([0-9]+)-page-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2;
    rewrite ^/thread-([0-9]+)\.html$ /showthread.php?tid=$1;
    rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&page=$2;
    rewrite ^/thread-([0-9]+)-lastpost\.html$ /showthread.php?tid=$1&action=lastpost;
    rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&action=nextnewest;
    rewrite ^/thread-([0-9]+)-nextoldest\.html$ /showthread.php?tid=$1&action=nextoldest;
    rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&action=newpost;
    rewrite ^/thread-([0-9]+)-post-([0-9]+)\.html$ /showthread.php?tid=$1&pid=$2;
    rewrite ^/post-([0-9]+)\.html$ /showthread.php?pid=$1;
    rewrite ^/announcement-([0-9]+)\.html$ /announcements.php?aid=$1;
    rewrite ^/user-([0-9]+)\.html$ /member.php?action=profile&uid=$1;
    rewrite ^/calendar-([0-9]+)\.html$ /calendar.php?calendar=$1;
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)\.html$ /calendar.php?action=yearview&calendar=$1&year=$2;
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /calendar.php?calendar=$1&year=$2&month=$3;
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
    rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /calendar.php?action=weekview&calendar=$1&week=$2;
    rewrite ^/event-([0-9]+)\.html$ /calendar.php?action=event&eid=$1;
        }
    location ~ /(inc|uploads/avatars) {
        deny all;
        }
    location ~* \.(jpg|jpeg|gif|png|css|ico|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           360d;
        }
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/conf/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/html/mybb/$fastcgi_script_name;
        }
    location ~ /\.ht {
        deny all;
        }
}

 

Open http://your-domain.com//mybb/install/ and follow the on-screen instructions.

MyBB will check if your server meets the requirements, and on the next page you will need to set the MySQL user and database information:

mybb database

Once the installation is complete, do not forget to delete the ‘install’ directory from your server:

rm -rf /var/www/html/mybb/install/

That is it. You successfully installed MyBB.

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 MyBB for you. They are available 24×7 and will take care of your request immediately.

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.

1 thought on “How to install MyBB on a LEMP (Linux + Nginx + MySQL + PHP-FPM) VPS”

Leave a Comment