I-Can-Code

Behalte diese Seiten unbedingt im Auge

How to install nextCloud with ssl on Debian 10 Buster

nextCloud is a flexible, self-hosted open source PHP web application. It can be used for data synchronization and file sharing. nextCloud is one of the best alternative for Google Drive, Box, Dropbox, iCloud and other cloud platforms. It have a lot of benefits, to self host your storege cloud like better privacy and storage limited by your own.

Installing nextCloud on Debian is simple and can be done by someone, who just have root access to the server. Let’s get started with installing nextCloud on your Debian 10 server.

If you need help, you can simply ask me via the contact form. I would be happy to install the nextCloud on your server for only € 50.

To can setup the server easily, you can install some good tools like Midnight Commander and sudo.

sudo apt install mc sudo apt-transport-https

1. Install MySQL Server

nextCloud can use MySQL/MariaDB, PostgreSQL or SQLite as a backend data storage. It have besser performance, if you use MariaDB. If you have a small vserver with limited ram so better go to step 3 and use just PostgreSQL. To install the MariaDB server  run the following command:

sudo apt install mariadb-server mariadb-client

When the installation is finish, run the following commands to start and enable the MariaDB service:

sudo systemctl start mariadb
sudo systemctl enable mariadb

To set a password just run the install helper from MariaDB:

sudo mysql_secure_installation

2. Create MySQL Database and User

To create the database and add a mysql user with full access for our nextCloud installation run the following commands:

mysql -u root -p
CREATE DATABASE nextcloud CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloud_passwd';
FLUSH PRIVILEGES;
\q

Install Redis

Redis is an in-memory database which will be used by the nextCloud installation as memory cache. It speed up everything a little bit. To install the latest Redis version run the following command:

sudo apt install redis-server redis-tools -y

3. Install Apache and PHP

nextCloud need an installed Apache and PHP modules. To install everything just run the following command:

sudo apt install apache2 libapache2-mod-php openssl php-imagick php-common php-curl php-gd php-imap php-intl php-json php-ldap php-mbstring php-mysql php-pgsql php-smbclient php-ssh2 php-sqlite3 php-xml php-zip php-redis php-apcu -y

When the installation is complete, run the following commands to start and enable the Apache service:

sudo systemctl start apache2
sudo systemctl enable apache2

4. Download and install nextCloud

The nextCloud package is not available in the default Debian 10 Buster repositories, so we must download the zip from nextCloud server.

cd /tmp
wget --no-check-certificate https://download.nextcloud.com/server/releases/latest.zip

Next, unzip the compressed file using the command and move everything to /var/www/

unzip latest.zip
mv nextcloud /var/www

The command above will install nextCloud in the /var/www/nextcloud directory. Everything you uploaded or need to change is in that directory.

Next you need to give everything www-data right, so it doesn`t operate as root user, which can create a major security problem.

cd /var/www
chown -R www-data:www-data nextcloud
chmod -R 755 nextcloud

5. Configure Apache

Next just configure the Apache webserver to serve the nextCloud directory create a new configuration file:

sudo mcedit /etc/apache2/sites-available/YOUR_HOST_NAME.conf

Add the Simple edit the YOUR_HOST_NAME with your hostname.

<VirtualHost *:443>
        SSLEngine on
	ServerName YOUR_HOST_NAME
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/nextcloud
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/nextcloud/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>
	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>
	ErrorLog ${APACHE_LOG_DIR}/error.log
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
	CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLCertificateFile /etc/letsencrypt/live/YOUR_HOST_NAME/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/YOUR_HOST_NAME/privkey.pem
 Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Enable the Apache nextCloud configuration and restart the Apache web server:

ln -s /etc/apache2/sites-available/YOUR_HOST_NAME.conf /etc/apache2/sites-enabled/100-YOUR_HOST_NAME.conf
a2enmod ssl proxy proxy_http proxy_ajp
service apache2 restart

6. Finish the nextCloud installation

In the last step of this guide we need to access to nextCloud Web Interface and finish the installation.

To finish the installation open your browser and navigate to https://YOUR_HOST_NAME/ or use the hostname, if you have setup one.

To create your first admin user enter the Username and Password under the “Create an admin account” label. Next click on “Storage & Database” link, which will give you an option to select your database backend.

Leave the default “Data Folder” value “/var/www/nextcloud/data”. Just edit the Database under the “Configure the database” label and select “MySQL/MariaDB”. In the database fields enter the database user, the database user password and the database name you previously created.

To finish the installation click on “Finish setup” button and the nextCloud installer will populate the database and redirect you to the nextCloud login screen.

Now you are finish! Quite easy or? If you need any help wite an comment or go to the official nextCloud User Manual.

,

Leave a Reply

Your email address will not be published. Required fields are marked *