A few people have asked questions on how to install Flarum in a public directory so I'm writing this tutorial on how to do so. This will be written in the context of Ubuntu. Keep in mind, use this tutorial at your own risk and I take no responsibly for any damages.
Step 1. Create Public Directory
mkdir public
(ensure you are in the root of Flarum)
Step 2. Move index.php, admin.php, and api.php
mv index.php public/ && mv admin.php public/ && mv api.php public/
Step 3. Edit index.php, admin.php, and api.php
nano public/index.php
and replace with:
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require '../vendor/autoload.php';
$server = new Flarum\Forum\Server(__DIR__ . '/..', __DIR__);
$server->listen();
nano public/admin.php
and replace with:
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require '../vendor/autoload.php';
$server = new Flarum\Admin\Server(__DIR__ . '/..', __DIR__);
$server->listen();
nano public/api.php
and replace with:
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require '../vendor/autoload.php';
$server = new Flarum\Api\Server(__DIR__ . '/..', __DIR__);
$server->listen();
Step 4. Symbolic Link Assets Directory
ln -sf assets public/assets
Step 5. Modify Web Server Config
You'll need to manually modify your web server config to add public
to the root path.
Let me know if you run into any issues.