I am a newbie at coding, when I installed flarum for the first time, I found that I have to visit the forum in http://domain.com/public, I wasted a lot of time (2 days), read all related posts on Flarum Community, after many times frustration, I finally solved this problem in a very simple way, so I decide to open this thread, to share my solution for everyone, wish you guys won't waste so much time as I did.
Before I start the tutorial, I want to greatly thank:
@clarkwinkelmann
for his patient guide on https://discuss.flarum.org/d/17977-forum-public-why-not-just-forum/19
@luceos
for his guide on https://discuss.flarum.org/d/17795-help-with-public-paths/10
-------tutorial starts here-------
I installed Flarum 0.1.0-beta.12
PART ONE
In PART ONE, we move files and folders.
my original file structure on server is:
server
├── public_html
│ └── public
│ └── index.php
│ └── .htaccess
│ └── storage
│ └── vendor
│ └── flarum (executable)
│ └── config.php
│ └── site.php
Please do:
- Creat a folder
flarum
in the level of public_html
, and move all files and folders excepted public
to the new folder flarum
- Move all files and folders under
public
to public_html
, and delete public
.
Now new file structure on server looks like this
server
├── public_html
│ └── index.php
│ └── .htaccess
└── flarum
├── storage
├── vendor
└── flarum (executable)
└── config.php
└── site.php
PART TWO
In PART TWO, we modify key files.
Please do:
- Open site.php, and modify script from
return Flarum\Foundation\Site::fromPaths([
'base' => __DIR__,
'public' => __DIR__,
'storage' => __DIR__.'/storage',
]);
to
return Flarum\Foundation\Site::fromPaths([
'base' => '/home/customer/www/domain.com/flarum',
'public' => '/home/customer/www/domain.com/public_html',
'storage' => '/home/customer/www/domain.com/flarum/storage',
]);
- Open
config.php
, change 'url' => 'http://domain.com/public',
to 'url' => 'http://domain.com',
-------tutorial ends here-------
Congratulations!
And then everything is done, you can visit your flarum forum via http://domain.com
Cheers!
Suggestion
I think in Flarum Document, https://flarum.org/docs/install.html#customizing-paths should be updated and be more specific.
For Flarum 0.1.0-beta.12, no need to modify index.php
and flarum
(executable).