Traditional shared hosting installation
Preface
Choose a shared hosting provider that provides shell access (command line remote access to the server). These instructions assume the host gives you cPanel, or a similar GUI, and the host allows you to create folders one level below the public folder.
These instructions will not explain how to use cPanel, other hosting environments, or the exact steps for creating a database. Research all of that first.
1. Create folder
Create a folder one level below the public folder. Name it anything you’d like. Later, when using the command line, you will point to and download Flarum into this folder. For this example, let’s say it’s named, flarum.
2. Create database
Shared hosts typically have a database wizard. With a few clicks you can create a database, database user, and give that user all permissions. Make a note of the database name, username, and password for a later step.
3. Download Flarum
Using the host’s ssh interface or a client such as Termius execute these commands:
cd path/to/flarum
You may need to research the correct path that your hosting provider wants you to use, and here “flarum” is the name of the folder you created in step 1.
composer create-project flarum/flarum .
Once done, Flarum will now be one level below your public folder.
4. Move public files to your public folder
To be clear, you need to move the contents of the public folder that comes with Flarum, to your hosting provider’s public folder. You do not want the public folder itself in your host’s public folder. Because, you do not want to have to navigate to site.com/public to get to your forum.
5. Edit site.php and index.php
This step may require research. Every host may be different. You may not have to do anything, or you may need to edit the paths in site.php in the folder below your public folder, and index.php in your public folder.
As one example, you might need to change site.php to look something like this (but this may not work for you):
require 'vendor/autoload.php';
return Flarum\Foundation\Site::fromPaths([
'base' => '/home/customer/youraccount/flarum',
'public' => '/home/customer/youraccount/public_html',
'storage' => '/home/customer/youraccount/flarum/storage',
]);
Next, go to your public folder and edit the index.php file. Here you need to make sure you are pointing back to site.php correctly using a similar format as seen above (using a specific/direct/full path).
In short, site.php points to your public folder and things in your one level below folder. Then, index.php points to site.php.
6. Navigate to site and fill out install form
Go to your website. Fill in the Flarum install form with your database information and admin user credentials. A common practice for the database prefix is three letters and an underscore. Example: one_. Click install.
The page will redirect to your new Flarum forum. Congratulations!
7. Final adjustments
Add SSL certificate (let’s encrypt), forced https and force either the WWW version or non-WWW version of your site by adding the appropriate rules to the public .htaccess file.
Your host has these instructions or, search the web.