Flarum is an open-source, lightweight forum software designed for ease of use, with a powerful extension system, making it highly customizable. It’s built on PHP and integrates seamlessly with MySQL or MariaDB databases, offering a modern, responsive design. This guide aims to help newcomers through the detailed steps of installing Flarum on Ubuntu 23.04, providing real command-line examples for a straightforward setup process.
Step 1: Environment Setup
Flarum requires PHP, a web server (Apache or Nginx), and a MySQL or MariaDB database. Start by installing these components.
- Update Your System:
sudo apt update && sudo apt upgrade -y
- Install Apache:
sudo apt install apache2 -y
- Install MySQL:
sudo apt install mysql-server -y
Secure your MySQL installation:
sudo mysql_secure_installation
- Install PHP and Extensions: Flarum requires PHP 7.3 or greater. Install PHP along with necessary extensions:
sudo apt install php php-cli php-fpm php-mysql php-json php-gd php-curl php-mbstring php-xml php-zip -y
Step 2: Configuring MySQL for Flarum
Create a database and user for Flarum within MySQL.
- Access MySQL Prompt:
sudo mysql -u root -p
- Create a Database:
CREATE DATABASE flarum;
- Create a User and Grant Privileges: Replace
yourpassword
with a strong password.
CREATE USER 'flarumuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON flarum.* TO 'flarumuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Install Composer
Flarum is installed via Composer, a PHP package manager.
- Download Composer:
cd ~
curl -sS https://getcomposer.org/installer | php
- Move Composer to a global directory:
sudo mv composer.phar /usr/local/bin/composer
Step 4: Install Flarum
With the environment prepared, proceed to install Flarum.
- Create a Directory for Flarum:
sudo mkdir -p /var/www/flarum
sudo chown www-data:www-data /var/www/flarum
cd /var/www/flarum
- Install Flarum using Composer:
composer create-project flarum/flarum . --stability=beta
Step 5: Configure Apache for Flarum
Create an Apache virtual host file for Flarum.
- Create a New Configuration File:
sudo nano /etc/apache2/sites-available/flarum.conf
- Add the Following Configuration: Adjust
ServerName
to your domain or IP address.
<VirtualHost *:80>
ServerName your_domain_or_IP
DocumentRoot /var/www/flarum/public
<Directory /var/www/flarum/public>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- Enable the Site and Rewrite Module:
sudo a2ensite flarum.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 6: Finalizing Flarum Installation
Navigate to your website in a web browser to complete the Flarum installation through its web-based setup.
After successfully installing Flarum on Ubuntu 23.04, consider using Shape.host’s Cloud VPS services for hosting your Flarum forum. Shape.host offers reliable, scalable Linux SSD VPS solutions that provide the ideal environment for running Flarum. With Shape.host, you benefit from high-performance SSD storage, robust security features, and outstanding network connectivity, ensuring your forum operates smoothly and efficiently