In this topic, you will learn the following:

  • How to install Plesk without a local Plesk database but with one hosted on a remote database server.
  • Pros and cons of Plesk with the database hosted on a remote database server.
  • Plesk installation procedures for a dedicated and shared remote database server.
  • How to convert a remote Plesk database to a local one.

警告: Installing Plesk without the local database is a beta feature. We strongly recommend not to use it in production because the feature may contain bugs.

Plesk needs database servers to store its own psa database, databases used by its components, and databases created by hosting customers』 websites and applications (for example, a WordPress database). Plesk can work with database servers located on the same server with Plesk (local database servers) or on a remote machine (remote database servers).

By default, installing Plesk also installs a local database server. Plesk uses it to host its own psa database. It is true even if hosted websites use remote database servers.

However, you can install Plesk without using a local database and host the Plesk psa database on a remote database server.

備註: At the moment, you can use only Plesk for Linux with the remote database.

With the Plesk database hosted on a remote database server, you can do the following:

  • Outsource the database server support.
  • Use advanced web database management tools, for example, those offered by Amazon RDS.
  • Use a specific database service that cannot be installed on the same server as Plesk.
  • Host multiple Plesk databases on one centralized database server if you have more than one Plesk server.
  • Create a high availability infrastructure for Plesk by hosting the Plesk database on a multi-node database cluster (for example, MariaDB Galera Cluster). Plesk does not support local installation of MariaDB Galera Cluster.

The downsides of Plesk with a remote database are as follows:

  • Increases financial costs (be it an additional database server or AWS service).
  • Demands more time, effort, and expertise to install and maintain (compared with the default Plesk installation).

Installing Plesk With Its Database on a Remote Database Server

Prerequisites

  • A remote database server to host the Plesk database on.

  • A Linux server to install Plesk on. We will call it the Plesk server.

    備註: The Plesk server can run on any Linux distribution supported by Plesk.

The exact installation procedure varies depending on the type of your remote database server: dedicated or shared.

A dedicated database server does not have any databases or database users created earlier. You need to have the ability to create a database admin user with all privileges. Then the Plesk Installer script will automatically create the Plesk psa database.

A shared database server already has some databases and database users. You cannot create a database admin user with all privileges. Instead, you manually create all databases and database users necessary to run Plesk.

(Dedicated remote database server) To install Plesk with its database on a remote database server:

備註: Firstly, you need to install a database management system on the remote database server. For now, we recommend that you use MySQL: we have tested it and it proved to be a working scenario.

備註: Below you can see a step-by-step procedure for the remote database server running on Ubuntu. For other Linux distributions, refer to the Oracle documentation, and then go straight to step five of the procedure below.

  1. Log in to the remote database server and install the MySQL server:

    [mysql_server]$ wget https://repo.mysql.com//mysql-apt-config_0.8.22-1_all.deb
    [mysql_server]$ dpkg -i mysql-apt-config_0.8.22-1_all.deb
    [mysql_server]$ apt update
    [mysql_server]$ apt install mysql-server
    [mysql_server]$ locate my.cnf
    
  2. Add the information about the native password to my.cnf:

    [mysqld]
    default-authentication-plugin=mysql_native_password
    
  3. Restart the MySQL server to apply the changes:

    [mysql_server]$ systemctl restart mysql
    
  4. Enter the MySQL server application and create a database superuser:

    [mysql_server]$ mysql
    
    # welcome message output
    
    mysql> CREATE USER 'mysql_admin'@'%' IDENTIFIED BY '<password>';
    mysql> GRANT ALL ON *.* TO 'mysql_admin'@'%' WITH GRANT OPTION;
    
  5. Make sure the Plesk server has access to the remote database server. To do so, check the bind-address parameter value of the remote database system. It must be the following:

    bind-address = 0.0.0.0
    

    bind-address = <IP address of the remote database server the Plesk server will connect to>
    

    For more information on the bind-address parameter, refer to the MySQL or MariaDB documentation.

  6. Check the connection to the remote MySQL server from the Plesk server:

    # try to connect to the MySQL server from the Plesk server
    [another_server]$ mysql --host=mysql_server --user=mysql_admin --password=<password>
    
  7. Create a database admin user with all privileges:

    CREATE USER 'plesk_db_admin'@'%' IDENTIFIED BY '<plesk_db_admin_password>';
    GRANT ALL ON *.* TO 'plesk_db_admin'@'%' WITH GRANT OPTION;
    
  8. Log in to the Plesk server.

  9. On the Plesk server, run the Plesk installer script specifying the database admin user (created in the previous step) via the PLESK_DB_DSN_PREFIX environment variable:

    PLESK_DB_DSN_PREFIX=mysql://plesk_db_admin:<plesk_db_admin_password>@mysql_server/host1_ ./plesk-installer
    

    備註: To use specific database users and/or database names, use DSN environment variables per database instead of or together with the PLESK_DB_DSN_PREFIX variable. For example, to specify a database name for Plesk and keep everything else as default, specify the following environment variables:

    PLESK_DB_DSN_PREFIX=mysql://plesk_db_admin:<plesk_db_admin_password>@mysql_server/host1_
    PLESK_DB_DSN=mysql://plesk_db_admin:<plesk_db_admin_password>@mysql_server/host1_plesk
    

    In this case, after installing Plesk, the host1_plesk database will be created instead of host1_psa.

You have set up everything necessary to have Plesk host its database on the remote database server. The last step is to log in to Plesk for the first time.

(Shared database server) To install Plesk with its database on a remote database server:

備註: We presume that you have already set up a database management system (for example, MySQL) on the remote database server. If it is not true, consider referring to the procedure above for a dedicated database server. It contains an example of setting up the database management system.

  1. Log in to the remote database server and enter the MySQL server application:

    mysql
    
  2. Create databases and database users with privileges specified in the 「Database Users」 table:

    CREATE DATABASE host1_psa; # Plesk Database
    CREATE USER 'plesk_db_user'@'%' IDENTIFIED BY '<plesk_db_user_password>';
    GRANT ALL ON host1_psa.* TO 'plesk_db_user'@'%' WITH GRANT OPTION;
    
    CREATE DATABASE host1_apsc; # APSC Database
    CREATE USER 'apsc_db_user'@'%' IDENTIFIED BY '<apsc_db_user_password>';
    GRANT ALL ON host1_apsc.* TO 'apsc_db_user'@'%' WITH GRANT OPTION;
    
    CREATE DATABASE host1_roundcubemail; # Roundcube Webmail Database
    CREATE USER 'roundcube_db_user'@'%' IDENTIFIED BY '<roundcube_db_user_password>';
    GRANT ALL ON host1_roundcubemail.* TO 'roundcube_db_user'@'%' WITH GRANT OPTION;
    
    CREATE DATABASE host1_horde; # Horde Webmail Database
    CREATE USER 'horde_db_user'@'%' IDENTIFIED BY '<horde_db_user_password>';
    GRANT ALL ON host1_horde.* TO 'horde_db_user'@'%' WITH GRANT OPTION;
    
  3. On the Plesk server, run the Plesk installer script specifying the databases and database users (created in the previous step) via the following environment variables: PLESK_DB_DSN, PLESK_DB_APSC_DSN, PLESK_DB_ROUNDCUBE_DSN, and/or PLESK_DB_HORDE_DSN.

    PLESK_DB_DSN=mysql://plesk_db_user:<plesk_db_user_password>@mysql_server/host1_psa \
    PLESK_DB_APSC_DSN=mysql://apsc_db_user:<apsc_db_user_password>@mysql_server/host1_apsc \
    PLESK_DB_ROUNDCUBE_DSN=mysql://roundcube_db_user:<roundcube_db_user_password>@mysql_server/host1_roundcubemail \
    # and/or PLESK_DB_HORDE_DSN=mysql://horde_db_user:<horde_db_user_password>@mysql_server/host1_horde \
    ./plesk-installer
    
  4. Make sure the Plesk server has access to the remote database server. To do so, check the bind-address parameter value of the remote database system. It must be the following:

    bind-address = 0.0.0.0
    

    bind-address = <IP address of the remote database server the Plesk server will connect to>
    

    For more information on the bind-address parameter, refer to the MySQL or MariaDB documentation.

You have set up everything necessary to have Plesk host its database on the remote database server. The last step is to log in to Plesk for the first time.

Converting the Plesk Remote Database to a Local One

If you installed Plesk with a remote database and then changed your mind, you can convert the Plesk remote database to a local one and thus get the default Plesk installation.

備註: The vice-versa conversion is not supported at the moment. You cannot convert a local Plesk database to a remote one.

Prerequisites

  • A remote database server the Plesk database is hosted on.
  • A Linux server Plesk is installed on. We will call it the Plesk server.

To convert the Plesk remote database to a local one:

  1. Copy a dump of the following databases from the remote database server: psa, apsc, roundcubemail, and/or horde:

    plesk db dump host1_apsc host1_psa host1_roundcubemail > dump_from_host1.sql
    
  2. Remove prefixes (if any) from the database names:

    sed -i 's/host1_apsc/apsc/g' dump_from_host1.sql
    sed -i 's/host1_psa/psa/g' dump_from_host1.sql
    sed -i 's/host1_roundcubemail/roundcubemail/g' dump_from_host1.sql
    sed -i 's/host1_horde/horde/g' dump_from_host1.sql
    
  3. Log in to the Plesk server and rename the /etc/psa/private/dsn.ini file that contains the configuration data of the remote database. This will disable remote database support on the Plesk server:

    mv /etc/psa/private/dsn.ini /etc/psa/private/dsn.ini.backup
    
  4. Create a database admin user:

    PSA_PASSWORD=<new_admin_password> plesk sbin ch_admin_passwd
    
  5. Deploy the copied dump to the Plesk server:

    plesk db < dump_from_host1.sql
    
  6. Check the database for issues and fix them (if any) using the plesk repair db utility:

    plesk repair db
    

You have completed the conversion, and your Plesk now hosts its database on the local machine. You can now log in to your Plesk.

References

Database Users

image db users

Environment Variables

DSN environment variable for all databases by prefix

Environment Variable Value Format Description
PLESK_DB_DSN_PREFIX mysql://{plesk_db_admin}:{password}@{remote_db_host}/{db_prefix}

Specify this variable if you want Installer to create all the databases it needs by adding the specified db_prefix prefix to their names.

備註:

If db_prefix is left empty, the default database names will be used: psa, apsc, roundcubemail, and/or horde.

DSN environment variables per database

Environment Variable Value Format Description
PLESK_DB_DSN mysql://{plesk_db_user}:{password}@{remote_db_host}/{plesk_db_name}

Specify this variable if you want Installer to use plesk_db_name as the Plesk database name. The database must be added in advance, or plesk_db_user must have privileges to create the plesk_db_name database (for example, specify plesk_db_admin).

備註:

If plesk_db_name is left empty, the default psa name will be used.

PLESK_DB_APSC_DSN mysql://{apsc_db_user}:{password}@{remote_db_host}/{apsc_db_name}

Specify this variable if you want Installer to use apsc_db_name as the APSC database name. The database must be added in advance, or apsc_db_user must have privileges to create the apsc_db_name database (for example, specify plesk_db_admin).

備註:

If apsc_db_name is left empty, the default apsc name will be used.

PLESK_DB_ROUNDCUBE_DSN mysql://{roundcube_db_user}:{password}@{remote_db_host}/{roundcube_db_name}

Specify this variable if you want Installer to use roundcube_db_name as the Roundcube database name. The database must be added in advance, or roundcube_db_user must have privileges to create the roundcube_db_name database (for example, specify plesk_db_admin).

備註:

If roundcube_db_name is left empty, the default roundcubemail name will be used.

PLESK_DB_HORDE_DSN mysql://{horde_db_user}:{password}@{remote_db_host}/{horde_db_name}

Specify this variable if you want Installer to use horde_db_name as the Horde database name. The database must be added in advance, or horde_db_user must have privileges to create the horde_db_name database (for example, specify plesk_db_admin).

備註:

If horde_db_name is left empty, the default horde name will be used.