- Latest Laravel Long Term Support (5.5) or latest (5.6).
- PHP 7.0 or up, check the requirements for your Laravel version.
- Preferably Ubuntu. But most linux-based operating systems should work.
- Apache 2.4+ or Nginx 1.12+.
- MySQL 5.7+, MariaDB 10+ or PostgreSQL 9+.
Please note that MySQL limits username and database length to 32,
enable in the
tenancy.php configuration file:
website > uuid-limit-length-to-32
to fix this.
Elevated database user
Tenancy requires a system connection that allows creating new databases for her tenants. In order to do so we need to have a database user with elevated permissions.
A user for both MariaDB or MySQL and PostgreSQL would require the "GRANT OPTION" to be applied. You can either use the root user (for PostgreSQL that is user postgres) or create your own (recommended):
CREATE DATABASE IF NOT EXISTS tenancy; CREATE USER IF NOT EXISTS tenancy@localhost IDENTIFIED BY 'someRandomPassword'; GRANT ALL PRIVILEGES ON *.* TO tenancy@localhost WITH GRANT OPTION;
CREATE DATABASE tenancy; CREATE USER tenancy WITH CREATEDB CREATEROLE PASSWORD 'someRandomPassword'; GRANT ALL PRIVILEGES ON tenancy to tenancy WITH GRANT OPTION;
Make sure you configure this user as your system connection in your
'system' => [ 'driver' => 'mysql', 'host' => env('TENANCY_HOST', '127.0.0.1'), 'port' => env('TENANCY_PORT', '3306'), 'database' => env('TENANCY_DATABASE', 'tenancy'), 'username' => env('TENANCY_USERNAME', 'tenancy'), 'password' => env('TENANCY_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ]
There is no need to configure the
tenant connection in the
configuration file. This connection is set up automatically during runtime. Pre-
configuring this connection may cause unwanted behaviour.