# Install MyBB - Open Source Forum Software - on Linux

## What is MyBB?

> MyBB is the free and open source forum software powering thousands of engaging, vibrant, and unique communities across the internet. - https://mybb.com/

## Installation

1. Log into the Linux device
2. Run the following commands in a terminal:
   # update software repositories
   sudo apt update
   # install any available software updates
   sudo apt upgrade -y
   # install Apache HTTPD and MySQL
   sudo apt install apache2 mariadb-server mariadb-client wget zip -y
   # install PHP components
   sudo apt install php php-mysql php-common php-gd php-mbstring php-xml -y
   # configure the MySQL database
   sudo su
   mysql_secure_installation
3. Press Enter to login as root
4. Type N and press Enter to not switch to socket authentication
5. Type Y and press Enter to set a root password, type the password twice to confirm
6. Type Y and press Enter to remove anonymous users
7. Type Y and press Enter to disallow root login remotely
8. Type Y and press Enter to remove the test database
9. Type Y and press Enter to reload privilege tables
10. Run the following command to login into MySQL:
    mysql -u root -p
11. Authenticate with the root password set earlier
12. Run the following commands to create the mybb database and database user
    CREATE DATABASE mybb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    GRANT ALL ON mybb.* TO 'mybb_rw'@'localhost' IDENTIFIED BY 'My44_rw$';
    FLUSH PRIVILEGES;
    EXIT;
    exit
13. Continue with the following commands to download and extract MyBB to the webroot
    # fetch the latest download URL
    regex='"browser_download_url": "(https:\/\/github.com\/mybb\/mybb\/releases\/download\/[^/]*\/mybb_[^/]*\.zip)"' && response=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/mybb/mybb/releases/latest) && [[ $response =~ $regex ]] && downloadURL="${BASH_REMATCH[1]}"
    # download latest mybb version
    sudo wget -O /tmp/mybb.zip $downloadURL
    # extract the downloaded zip archive
    sudo unzip /tmp/mybb.zip -d /var/www/html
    # delete the Documentation directory
    sudo rm /var/www/html/Documentation -R
    # rename mybb folder
    sudo mv /var/www/html/Upload /var/www/html/mybb
    # rename htaccess file
    sudo mv /var/www/html/mybb/htaccess.txt /var/www/html/mybb/.htaccess
    # set permissions
    sudo chown -R www-data:www-data /var/www/html/mybb
    # create a config file
    sudo touch /var/www/html/mybb/inc/config.php
    # make some files writable
    sudo chmod 666 /var/www/html/mybb/inc/config.php /var/www/html/mybb/inc/settings.php
    sudo chmod 777 /var/www/html/mybb/cache/ /var/www/html/mybb/cache/themes/ /var/www/html/mybb/uploads/ /var/www/html/mybb/uploads/avatars/
14. Open a web browser and navigate to http://DNSorIP/mybb
15. Click Next at the Welcome screen
16. Click Next at the License Agreement
17. Click Next at the Requirements Check
18. Complete the Database Configuration as shown below

    Database Engine: MySQL Improved
    Database Server Hostname: localhost
    Database Username: mybb_rw
    Database Password: My44_rw$
    Database Name: mybb
    Table Prefix: mybb_

19. Click Next after the table creation completes
20. Click Next to complete the Table Population
21. Click Next at the Theme Insertion screen
22. Modify the Board Configuration form as needed > Click Next
23. Create an administrator account by entering a Username, Password and Email Address > Click Next
24. Back in the terminal, remove the /install directory with the following command
    # remove the install directory
    sudo rm /var/www/html/mybb/install -R
25. Back in the browser, navigate to http://DNSorIP/mybb/admin/index.php
26. Login with the administrator username and password created earlier
27. Welcome to MyBB

Source: https://docs.mybb.com/1.8/install/