Flarum is the best forum software available today. On a mobile device, it looks and feels like an app. On a desktop, it looks amazing. But, it’s not just the looks… it’s fast and has excellent features and extensions.
But. It’s not easy for a non-web-tech-savvy type person to install it. Many people get shared web hosting due to cost and/or familiarity, and they can go into something like Softaculous, click on what they want to install (maybe WordPress), and in seconds that app is installed. Flarum requires Composer and SSH access to be installed. Well, there are a couple tutorials out there which offer ways to do it without Composer or SSH, but, this is the standard way.
“Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.” – https://getcomposer.org/doc/00-intro.md
The good news is, more and more, shared web hosting companies offer SSH access and have Composer installed.
First, get your PHP version changed to 7.2 or higher. Go to cPanel > Software section > Select PHP Version menu. Change the version and save.
Next, make sure you have some important PHP extensions enabled. To enable other extensions go to cPanel > Software section > Select PHP Version menu. Make sure that the following extensions are selected and click Save:
openssl (not in PHP 7.3+, but that’s ok)
Leave all the default extensions checked. So, you aren’t unchecking anything, just possibly checking a few extra things.
Now you need to install a SSH client. One great option is Terminus. This is because they offer it for iPhone, Android, Windows, OSX, Chromebook… and it looks nice and is really easy to use. And it is free, unless you want some advanced features. But, there are other options – Google “Free SSH client.”
Get the SSH client installed on your computer/device. Then, search your web host’s knowledgebase for how to connect to SSH remotely, using a SSH client. Essentially, you will be inputting settings such as:
username – your cPanel username
password – your cPanel password
servername – name of the server where your hosting account is located (search your host’s knowledgebase or ask them)
port – (SSH port – search your host’s knowledgebase or ask them)
Connect to your server using the SSH client.
So far, you have a shared hosting account with cPanel, the right PHP version and extensions, and you are connected in your SSH client.
Finally, in cPanel, go to file manager. One level below the www or public_html directory, create a folder. Name it whatever you want. You’ll use this later.
Now, in your SSH client terminal window, type cd public_html, hit enter. That’s the most common name for the main public directory on shared hosts. Just note that throughout these instructions, you might be using a different name for this folder depending on the host. Now you are in public_html.
composer create-project flarum/flarum . --stability=beta
Now composer is getting everything downloaded onto your server in public_html.
You now have everything loaded onto the shared server in your public_html directory. But, don’t finish the installation just yet! Right now, you have sensitive files which aren’t secure. Remember the folder you created one level below public_html? Using the SSH client if you know how, or using cPanel’s file manager, move all the files you just installed to the folder you created below public_html EXCEPT the files in the Public folder. Also, don’t just leave the Public folder there. You can pull out Assets, .htaccess, and index.php, and make sure those three are in your public_html folder. Again, everything else, you move below the root (below public_html) into that folder you created at the beginning.
So now, you have the core senstive files, below the root (so common folk can’t access them) and the public files (assets, .htaccess, index.php) in public_html.
Next, edit both index.php (in public_html) and the flarum executable (in your below the root folder) and update the paths in the following lines to reflect your new directory structure:
require 'vendor/autoload.php'; 'base' => __DIR__, 'public' => __DIR__, 'storage' => __DIR__.'/storage',
This is what your code might look like for index.php:
require '/home/username/folderyoucreated/vendor/autoload.php'; $server = new FlarumHttpServer( FlarumFoundationSite::fromPaths([ 'base' => '/home/username/folderyoucreated', 'public' => '/home/username/public_html', 'storage' => '/home/username/folderyoucreated/storage', ]) ); $server->listen();
Flarum executable should look like this:
require 'vendor/autoload.php'; $server = new FlarumConsoleServer( FlarumFoundationSite::fromPaths([ 'base' => __DIR__, 'public' => __DIR__.'/public', 'storage' => __DIR__.'/storage', ]) ); $server->listen();
Finally, visit your forum in a web browser and follow the installation instructions. You will also need to first set up the database and those instructions will be added here one day… But in short, in cPanel, use the database wizard.
There will be other things to do, maybe some hiccups… You will have to decide if you are using SSL or not (https vs. http), you might also add a rule in .htaccess so that www redirects to non-www or vice versa. But, all of that you will need to research and figure out.