Step 1: Login in Root & Update system
sudo su
apt-get update
Step 2: Install LAMP Server + PHP Extension
apt-get install lamp-server^
apt-get install libapache2-mod-php7.1 php7.1-mbstring php7.1-curl php7.1-zip php7.1-gd php7.1-mysql php7.1-mcrypt
apt-get install php-xml
Step 3: Go to webroot Directory and Download latest NextCloud server 17.0.1
cd /var/www/html
wget https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip
Step 4: Unzip + Permissions
unzip nextcloud-17.0.1.zip
mv nextcloud-17.0.1 nextcloud
rm -rf nextcloud-17.0.1.zip
chown -R www-data:www-data nextcloud/
Step 5: Configuring MariaDB for NextCloud
mysql_secure_installation
Type Y for all except root password
Step 6: Create a database for nextcloud
sudo mysql -uroot -p (provide your MySQL root password)
use mysql;
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloud123';
FLUSH PRIVILEGES;
exit;
Step 7: Disable MariaDB binary logging
nano /etc/mysql/my.cnf
Add the following three lines at the end:
log-bin = /var/log/mysql/mariadb-bin
log-bin-index = /var/log/mysql/mariadb-bin.index
binlog_format = mixed
Step 8: Configuring Apache Web Server
sudo a2enmod rewrite
touch /etc/apache2/sites-available/nextcloud.conf
ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
Step 9: Create VirtualHost if needed
nano /etc/apache2/sites-available/nextcloud.conf
Add the following:
<VirtualHost *:80>
ServerAdmin admin@ubuntu
DocumentRoot "/var/www/html/nextcloud/"
ServerName ipaddress
ServerAlias ubuntu
<Directory "/var/www/html/nextcloud/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common
</VirtualHost>
Restart the Apache webserver
systemctl restart apache2.service
Open in web browser
http://127.0.0.1/nextcloud OR http://ipaddress/nextcloud
Referenece: https://docs.nextcloud.com/server/17/admin_manual/installation/index.html