Install from the command line
You can install Nextcloud without using the web-based Installation Wizard. This is useful for automated deployments, headless servers, and administrators who prefer the command line.
Before continuing, download and unpack the Nextcloud archive, configure the web server and PHP, and create the database and database user when using MySQL, MariaDB, PostgreSQL, or Oracle.
For the complete manual-installation prerequisites, see Installation on Linux.
Ensure that the HTTP user has read and write access to all Nextcloud directories. Changing ownership is the usual approach; for example, on Debian/Ubuntu:
$ sudo chown -R www-data:www-data /var/www/nextcloud/
Ownership is not strictly required. For example, where changing ownership is not possible, add the HTTP user to the group that owns the directories and ensure that they are group-writable. See Running occ.
Use the
occcommand to complete the installation. This takes the place of the graphical Installation Wizard. Runoccas the HTTP user so that ownership and permissions remain consistent with the web server:$ sudo -E -u www-data php /var/www/nextcloud/occ maintenance:install \ --database mysql --database-name nextcloud \ --database-user nextcloud \ --admin-user admin
This command prompts for the database and administrator passwords. For unattended installations, specify
--database-passand--admin-passusing your deployment system’s protected secret-handling mechanism. Avoid exposing production passwords in shell history or process listings.You can invoke
occfrom any directory when using its absolute path, as in the example above. Alternatively, change to the Nextcloud root directory and runsudo -E -u www-data php occ maintenance:install.Use
--database-hostand, if necessary,--database-portwhen the database runs on another host. Use--data-dirto select a data directory other than the default. To view all supported options, run:$ sudo -E -u www-data php /var/www/nextcloud/occ maintenance:install --help
When the database runs on another host, encrypt the connection using the
--database-ssl-*options described in Encrypted database connection below.
Supported databases are:
sqlite(SQLite)mysql(MySQL/MariaDB)pgsql(PostgreSQL)oci(Oracle; contact Nextcloud GmbH for enterprise support)
The selected database requires its corresponding PHP extension or driver to be installed and enabled.
Encrypted database connection
Added in version 35.
When the database does not run on the same host as Nextcloud, the connection should be encrypted so that the credentials and all queries are not sent in plaintext. The following options configure this during the installation, so that the installation itself already uses an encrypted connection:
Option |
Supported by |
Description |
|---|---|---|
|
|
Encryption mode of the connection, for example |
|
|
Path to the CA certificate the database server is verified against. |
|
|
Path to the client certificate used to authenticate against the database server. |
|
|
Path to the private key belonging to the client certificate. |
|
|
Path to the certificate revocation list. |
|
|
Do not verify that the certificate of the database server matches the
hostname used to connect. MySQL and MariaDB verify this by default,
PostgreSQL only in the |
--database-ssl-cert and --database-ssl-key have to be provided
together. Passing an option that the selected database does not support aborts
the installation with an error — sqlite and oci support none of them.
The certificates and keys have to be readable by the PHP process.
This example installs Nextcloud with a remote MySQL database, verifying the server against a CA certificate:
$ sudo -E -u www-data php /var/www/nextcloud/occ maintenance:install \
--database mysql --database-name nextcloud \
--database-host db.example.com \
--database-user nextcloud \
--database-ssl-ca /etc/ssl/nextcloud/ca-cert.pem \
--admin-user admin
Nextcloud writes the resulting configuration to dbdriveroptions
(MySQL/MariaDB) or pgsql_ssl (PostgreSQL) in config.php, see
Configuration Parameters. The same
connection can be configured for the Installation Wizard, see
Encrypted database connection.
See Command line installation for more information.