clarkwinkelmann you could just symlink the composer.json, composer.lock and vendor folder of all installs
That makes sense. Thank you for advice.
clarkwinkelmann you could just symlink the composer.json, composer.lock and vendor folder of all installs
That makes sense. Thank you for advice.
clarkwinkelmann It's interesting to note that every Flarum hosting service so far has been using one install per tenant (in particular: FreeFlarum).
FreeFlarum is multi tenant (the term this topic is about). It runs all tenants on one code base. That's also the reason why extensions are installed (not enabled though) for all tenants at once.
Multi tenancy in Flarum is something you can achieve by overriding/extending the bootstrap (which is maintained for these reasons in https://github.com/flarum/flarum).
An easy way to achieve multi tenancy also is by editing config.php
doing a hostname look up and including different configuration files based on the request.
An example for the last one (based on the old multi tenant locale support forums):
config.php
<?php
$host = array_get($_SERVER, 'HTTP_HOST');
if (! file_exists("tenants/$host.php")) {
$host = "default";
}
return require "tenants/$host.php";
This assumes that in your Flarum root you have a directory tenants
where each hostname has it's own config and there's a default.php for your fallback:
config.php
tenants/
default.php
example.com.php
Please note you will run into some issues like:
Which you'll need to take care of as well. For this reason it's wiser to create an extension. I've been working on one (for a pretty long time without any considerable progress) which might become a paid extension on the Flagrow extension marketplace at some point.
luceos FreeFlarum is multi tenant (the term this topic is about). It runs all tenants on one code base.
woops I was certain to have read the opposite. My bad then.
I am no experienced but I've been using a trick when flarum gets some sort of error to copy the sql clean the database, install and run the sql. (This is all theoretical and based on my vague coding knowladge) Couldn't you install a flarum, remove the contents on the database, install another one remove again and simply get an sql code and enter it in the database? I will test this when I have time.
RelatedTitle you're talking about how to generate multiple Flarum databases ?
The easiest solution would be to just install a blank Flarum, export as SQL (in MySQL Workbench or phpMyAdmin for example) then run that script again in every new database. Done.
If you're trying to automate it and maybe include updates or other extensions at the same time, have a look at the migrations. Migrations are a Laravel thing that allows you to version your database structure. For example in my Flarum migration service I just have the migrations of Flarum core and all default extensions I install in a folder, load them into the (Flarum-compatible, because there are a few tricks) Laravel Migration manager, connect it to an empty database and run them.
clarkwinkelmann No about running 2 flarums from a same database
RelatedTitle The question was more about (2 or more databases, 2 or more subdomains, 2 or more language extensions and single Flarum core)
Obviously it's possible to achieve, but with good skills in web development. I would go separate installations for now.
Solaris I realized this thread has not been active for half a year or so, but wpmu (wordpress multisite) is also about having multiple sites / domains on single install and database.
I do think that Flarum forum software can do the same as this has been done in other forum software like SubForums Mod for SMF and Multi Tenancy Addon for ElkArte.
I am personally attempting the same for Flarum but I need to familiar myself with Flarum extension system first. Currently hacking config.php works whether multi sites are on similar or different domains / subdomains.
I have https://sahabat.ahrasis.com and https://flarum.sch.my, https://fossm.sch.my and https://alpha.sch.my currently running on one installation and one database and nginx web server.
You will notice that https://alpha.sch.my is not working properly because I didn't create a vhost for it as this approach requires one nginx vhost for each domain / subdomain.
I am currently studying Flarum SEO for url rewriting; and Doorman and Default Group extensions for automatic registration via diferrent domains or subdomains.
I am a slow learner but I think I can get there sooner or later.
Hi all. I have a related but slightly different situation which I wonder if anyone in this thread could give any advice on. I would like to have the same forum (i.e. all the same posts) running on various different URLs. For example http://client1.example.com/ and http://client2.example.com/. The idea being that I will allow users from two different clients to interact with each other in the same forum, but each one running on their own subdomain.
I have already modified the config.php file so that rather than the URL being hard-coded it picks it up from the $_SERVER variables and it seems to work fine (so assets, for example, load properly from their own subdomain). I just wanted to know if anyone else has tried anything similar or if anyone know if anything that might cause a problem.
At the moment the only issue I saw is where the URL of uploaded images (using the fof/upload
extension) is embedded within posts, however I was able to get around this by uploading to S3 so the client-specific URL isn't embedded in the post.
Has anyone else done this? Or is there anything else that I should watch out for?
Thanks!
####
louieakil please do not double-post. We have an editing feature.
To my knowledge there is no extension covering the various use cases discussed in this thread and I'm not working on any such extension.
Because the suggestions here are so diverse I suggest you open a new Support discussion explaining your own use case so we can see whether a known solution applies to you.
clarkwinkelmann Thanks I just did
Xavier luceos' example just shows how to switch which config file is loaded depending on the requested hostname. The content of the host-specific config.php
file is not shown in the example, it would just be any valid config.php
file for Flarum. I assume in this example the url
value would be hard-coded in each specific host config file.
The only outdated part with the example is I think array_get
, which was a Laravel utility method that no longer exists. Must use the Arr
helper or just a native PHP array key access.
The example is potentially dangerous if the webserver does not validate the Host
header. The script is opened to directory transversal attacks that allows executing any PHP file on the server by providing a relative path as the Host
value. The host value should be validated with a regular expression.
clarkwinkelmann Thank you for telling me this, I think I would try it, thought it might be potentially dangerous.
A COUNTRY asks for all the websites to be recorded, and monitored if you want to make sure that your website is not blocked in its land. Unfortunately, my domain was blocked with just no reason (it's just a tech discussion forum), and I have to use another domain if I want my website to be available in the country, but I do not want to change my domain for the users in other countries, that's why me, and some other webmasters from the country need multisite function.
Xavier this discussion is about multi-tenant installations, where the same code is used for multiple different websites with their own separate databases.
Making a single forum accessible through multiple URLs is not recommended as it will negatively impact your SEO score in many search engines. This can be achieved by dynamically setting the url
value inside of the unique config.php
file, switching between config files will also work but is not necessary if the domain is the only difference. I think there exist other discussions about this on the forum. Otherwise, please start a new one so we can keep things organized.
clarkwinkelmann I have searched, and didn't found related discussions, I have posted a new one. https://discuss.flarum.org/d/32291-how-to-config-a-dynamically-url