How to Install MyBB Forum with Nginx and Let's Encrypt on Debian 10
On this page
- Requirements
- Prerequisites
- Initial steps
- Step 1 - Install PHP and required PHP extensions
- Step 2 - Install acme.sh client and obtain Let's Encrypt certificate ( optional )
- Step 3 - Install MariaDB and create a database for MyBB
- Step 4 - Install and configure Nginx
- Step 5 - Install MyBB
- Step 6 - Complete the MyBB setup
MyBB is a free and open-source, intuitive and extensible forum program. MyBB is simple to use and extendible with hundreds of plugins and themes that make adding new features or new look easy.
MyBB source code is hosted on GitHub. This tutorial will show you how to install MyBB forum software on Debian 10 (buster) system.
Requirements
MyBB 1.8 and the Merge System 1.8 have a few minimum system requirements:
- PHP, at least version 5.2. PHP 7.3 highly recommended.
- MySQL version 5.0 or greater, PostgreSQL version 8.1 or greater, or SQLite version 3 or greater. PostgreSQL 10.0 or MySQL 8.0 are highly recommended.
- Apache, Nginx, Lighttpd or IIS webserver
- The following PHP extensions are also needed:
- SimpleXML
- mbstring
- gd
- The respective vendor-specific database PHP extension
NOTE: Replace all instances of example.com
with your domain name.
Prerequisites
- A Debian 10 (buster) operating system.
- A non-root user with
sudo
privileges.
Initial steps
Check your Debian version:
lsb_release -ds
# Debian GNU/Linux 10 (buster)
Set up the timezone:
sudo dpkg-reconfigure tzdata
Update your operating system packages (software). That is an essential first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:
sudo apt update && sudo apt upgrade -y
Install some essential packages that are necessary for basic administration of the Debian operating system:
sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https
Step 1 - Install PHP and required PHP extensions
Install PHP, as well as the required PHP extensions:
sudo apt install -y php php-cli php-fpm php-gd php-mbstring php-xml php-mysql php-pgsql
To show PHP compiled in modules, you can run:
php -m
ctype
curl
exif
fileinfo
. . .
. . .
Check the version:
php --version
# PHP 7.3.9-1~deb10u1 (cli) (built: Sep 18 2019 10:33:23) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.4-2, Copyright (c) 1999-2018, by Zend Technologies
PHP-FPM service is automatically started and enabled on reboot on the Debian 10 system, so there is no need to start and enable it manually. We can move on to the next step.
Step 2 - Install acme.sh client and obtain Let's Encrypt certificate ( optional )
Securing your forum with HTTPS is not necessary, but it is a good practice to secure your site traffic. To obtain a TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a simple UNIX shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies.
Download and install acme.sh:
sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~
Check acme.sh version:
acme.sh --version
# v2.8.2
Obtain RSA and ECC/ECDSA certificates for your domain/hostname:
# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256
If you want fake certificates for testing, you can add --staging
flag to the above commands.
After running the above commands, your certificates and keys will be in:
- For RSA:
/home/username/example.com
directory. - For ECC/ECDSA:
/home/username/example.com_ecc
directory.
To list your issued certs you can run:
acme.sh --list
Create a directory to store your certs. We will use the /etc/letsencrypt
directory.
mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc
Install/copy certificates to /etc/letsencrypt directory.
# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
All the certificates will be automatically renewed every 60 days.
After obtaining certs exit from root user and return to regular sudo user:
exit
Step 3 - Install MariaDB and create a database for MyBB
Install MariaDB database server:
sudo apt install -y mariadb-server
Check the MariaDB version:
mysql --version
# mysql Ver 15.1 Distrib 10.3.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Run mysql_secure installation
script to improve MariaDB security and set the password for MariaDB root
user:
sudo mysql_secure_installation
Answer each of the questions:
Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Connect to MariaDB shell as the root user:
sudo mysql -u root -p
# Enter password
Create an empty MariaDB database and user for MyBB forum and remember the credentials:
mariadb> CREATE DATABASE dbname;
mariadb> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mariadb> FLUSH PRIVILEGES;
Exit from MariaDB:
mariadb> exit
Replace dbname,
username
and password
with your own names.
Step 4 - Install and configure Nginx
Download and install NGINX from the Debian repository:
sudo apt install -y nginx
Check the NGINX version:
sudo nginx -v
# nginx version: nginx/1.14.2
Configure Nginx. Run sudo vim /etc/nginx/sites-available/mybb.conf
and populate the file with the following.
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name forum.example.com;
root /var/www/mybb;
location / {
index index.php;
}
# Deny access to internal files.
location ~ /(inc|uploads/avatars) {
deny all;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Activate the new mybb.conf
configuration by linking the file to the sites-enabled
directory:
sudo ln -s /etc/nginx/sites-available/mybb.conf /etc/nginx/sites-enabled/
Check NGINX configuration for syntax errors:
sudo nginx -t
Reload Nginx:
sudo systemctl reload nginx.service
Step 5 - Install MyBB
Create a document root directory:
sudo mkdir -p /var/www/mybb
Download the latest release of MyBB and unzip it:
cd /var/www/mybb
sudo wget https://resources.mybb.com/downloads/mybb_1821.zip
sudo unzip mybb_1821.zip
sudo mv /var/www/mybb/Upload/* /var/www/mybb
Remove the downloaded .zip
file:
sudo rm mybb_1821.zip
sudo rmdir Upload
Change ownership of the /var/www/mybb
directory to www-data:
sudo chown -R www-data:www-data /var/www/mybb
As the last step, open your domain and follow the installation wizard for MyBB. To access the installer you must navigate to the /install
directory of your site in your web browser. For example, if your domain is example.com
and you uploaded your MyBB files to the root directory then navigate to http://example.com/install
. To access MyBB admin, append /admin
to your site URL. You have successfully installed your MyBB.
After the installation, you should remove the /install
directory from your server to prevent anyone else from running the installation again.
sudo rm -rf /var/www/mybb/install/
Step 6 - Complete the MyBB setup
To access the installer you must navigate to the install/
directory of your site in your web browser.
After opening the MyBB installation wizard you should be presented with a page like this. All you need to do is click "Next" on this page:
Check the MyBB license and click "Next":
This page checks that your server meets the requirements for running MyBB. If it does not, you will be notified on this page. If everything is working correctly, all you need to do is click on the "Next" button on this page.
This page is for the configuration of your database. Enter the requested database details and click "Next".
In this step, the database tables are inserted. No user input is needed on this page, so click the "Next" button when it appears.
In this step, the default data is inserted into the database tables created above. Click "Next".
The theme data is loaded into the forum in this step. No user input is necessary on this page. Click the "Next" button when it appears.
Next, configure basic settings like forum name, URL, etc:
Create a MyBB administrator account. This account has permissions to all sections in the Admin Control Panel.
After the creation of the admin account, you will see the "Finish Setup" page. That page shows that installation is completed:
To access admin interface append /admin to your URL:
MyBB admin will look something like this:
And here is the screenshot of MyBB frontend:
Congratulations! You have successfully installed your MyBB.