<\/span><\/h2>\nFirst, you need to install a web server to run Nextcloud. By executing the following command you will install the Apache web server on your VPS.<\/p>\n
apt-get install apache2<\/pre>\nYou can start Apache and also enable to start on server boot with these commands:<\/p>\n
systemctl start apache2\r\nsystemctl enable apache2<\/pre>\n<\/span>Install PHP<\/span><\/h2>\nInstall PHP together with some PHP modules that are required by Nextcloud.<\/p>\n
apt install php7.0 libapache2-mod-php7.0 php7.0-common php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt php7.0-imagick php7.0-xml php7.0-zip<\/pre>\n<\/span>Install MariaDB and create a database<\/span><\/h2>\nAs mentioned in the requirements, a database server is required to run NextCloud. We will install MariaDB server using the command:<\/p>\n
apt-get -y install mariadb-server<\/pre>\nOnce installed, start the database server and enable it to start at server boot.<\/p>\n
systemctl start mariadb\r\nsystemctl enable mariadb<\/pre>\nYou can run the mysql_secure_installatio<\/strong>n which is a post-installation script used to improve the security of your MariaDB server and set a \u2018root\u2019 password. You may use the options below<\/p>\nmysql_secure_installation<\/pre>\nSet root password? [Y\/n] Y\r\nRemove anonymous users? [Y\/n] Y\r\nDisallow root login remotely? [Y\/n] Y\r\nRemove test database and access to it? [Y\/n] Y\r\nReload privilege tables now? [Y\/n] Y<\/pre>\nNext step is to log in to the MariaDB server as ‘root’ user and creates a database and user for Nextcloud.<\/p>\n
mysql -u root -p<\/pre>\nMariaDB [(none)]> CREATE DATABASE nextcloud;\r\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'Password';\r\nMariaDB [(none)]> FLUSH PRIVILEGES;\r\nMariaDB [(none)]> exit;<\/pre>\nIt is recommended to replace \u2018Password\u2019 with a strong password which will be a combination of letters and numbers and at least 10 characters long.<\/p>\n
<\/span>Download and install Nextcloud<\/span><\/h2>\nGo to Nextcloud\u2019s official website and download Nextcloud 14 to your Debian 9 VPS. Currently, the latest stable version is 14.0.0<\/p>\n
wget https:\/\/download.nextcloud.com\/server\/releases\/nextcloud-14.0.0.zip<\/pre>\nExtract the downloaded ZIP archive Nextcloud-14.0.0.zip in a directory that Apache has access to, and change the ownership of the Nextcloud directory to the web server user.<\/p>\n
unzip nextcloud-14.0.0.zip -d \/var\/www\/html\/\r\nchown -R www-data:www-data \/var\/www\/html\/nextcloud\/<\/pre>\nOnce all of the Nextcloud prerequisites are met, we can complete the installation using two different ways: using the on-screen installation wizard or via the command line. In this case, we are going to use the installation via the command line. We will change the current working directory with this command:<\/p>\n
cd \/var\/www\/html\/nextcloud<\/pre>\nnow run the following command as web server user (www-data):<\/p>\n
sudo -u www-data php occ maintenance:install --database \"mysql\" --database-name \"nextcloud\" --database-user \"nextcloud_user\" --database-pass \"Password\" --admin-user \"admin\" --admin-pass \"Password\"<\/pre>\nYou should use the database information we created previously in this tutorial and replace the ‘Password’ with a strong password for the Nextcloud \u2018admin\u2019 user.<\/p>\n
You will get the following output if the installation is successful<\/p>\n
Nextcloud was successfully installed<\/pre>\nAdd your_domain.com by editing the config\/config.php file<\/p>\n
nano config\/config.php<\/pre>\n'trusted_domains' =>\r\narray (\r\n0 => 'localhost',\r\n1 => 'your_domain.com',\r\n),<\/pre>\n