Nextcloud is a suite of client-server software for creating and using file hosting services. It is functionally similar to Dropbox, although Nextcloud is free and open-source, allowing anyone to install and operate it on a private server.
In contrast to proprietary services like Dropbox, the open architecture allows adding additional functionality to the server in form of applications and enables the user to have full control of their data.
The original ownCloud developer Frank Karlitschek forked ownCloud and created Nextcloud, which continues to be actively developed by Karlitschek and other members of the original ownCloud team.
Assumptions
- your server is
example.comand it is running Ubuntu 16.04; - you already have a configured subdomain in the dns:
nextcloud.example.com; - your sudo user is
admin; - the user you want to create for NextCloud is
nextcloud; - the database main user is
rootand the password ismysqlpassword; - the database you will use is named
nextclouddbwith the usernextclouddbuserwith the passwordpassword
Create a new user and add it to Apache group
sudo adduser nextcloudsudo usermod -a -G www-data nextcloud
Create the virtualhost for Apache
Apache specials
Please be sure to have an Apache configuration similar to what the following commands give:
sudo a2enmod rewritesudo a2enmod headerssudo a2enmod envsudo a2enmod dirsudo a2enmod mimesudo a2enmod sslsudo a2ensite default-sslsudo service apache2 restart
Actually creating the host
su - nextcloudcd ~mkdir public_htmlchmod 755 ./public_htmlexitsudo chgrp -R www-data /home/nextcloud/public_htmlsudo chmod -R g+w /home/nextcloud/public_htmlsudo nano /etc/apache2/sites-available/nextcloud.example.com.conf-
<VirtualHost *:80> <Directory "/home/nextcloud/public_html"> Allow from all Options +Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / AllowOverride All </IfModule> <IfModule mod_dav.c> Dav off </IfModule> </Directory> DocumentRoot /home/nextcloud/public_html ServerName nextcloud.example.com SetEnv HOME /home/nextcloud/public_html SetEnv HTTP_HOME /home/nextcloud/public_html </VirtualHost> sudo a2ensite nextcloud.example.com.confsudo service apache2 reload
Create the database
mysql -uroot -pmysqlpassword -e "CREATE DATABASE nextclouddb /*\!40100 DEFAULT CHARACTER SET utf8 */;"mysql -uroot -pmysqlpassword -e "CREATE USER nextclouddbuser@localhost IDENTIFIED BY 'password';"mysql -uroot -pmysqlpassword -e "GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextclouddbuser'@'localhost';"mysql -uroot -pmysqlpassword -e "FLUSH PRIVILEGES;"sudo nano /etc/mysql/my.cnf
Addbinlog-format = MIXED
Install other packages
sudo apt-get install apache2 mariadb-server libapache2-mod-php7.0sudo apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstringsudo apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zipsudo apt-get install unzip
NextCloud
sudo su - nextcloudcd ~/public_htmlwget https://download.nextcloud.com/server/releases/latest-13.tar.bz2 -O nextcloud-13-latest.tar.bz2tar -xvjf nextcloud-13-latest.tar.bz2rm nextcloud-13-latest.tar.bz2cd nextcloudmv ./* ../cd ..rm -rf nextcouldsudo chmod 0770 /home/nexcloud/public_html/data
Access http://nextcloud.example.com to finish the setup. Also, be sure to check:
Also, do remember to check the firewall rules.
Activate SSL
sudo add-apt-repository ppa:certbot/certbotsudo apt-get updatesudo apt-get install python-certbot-apachesudo certbot --apache -d nextcloud.example.comsudo su - nextcloudnano /home/nextcoud/public_html/config/config.php
Change the option foroverwrite.cli.urlfromhttp://tohttps://
Activate opcache
sudo su - nextcloudnano /home/nextcloud/php.iniopcache.enable=1 opcache.enable_cli=1 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1Ctrl+xandYto saveexitsudo nano /etc/apache2/sites-available/nextcloud.example.com.conf- add
PHPINIDir /home/nextcloudbelow theServerNameline sudo nano /etc/apache2/sites-available/nextcloud.example.com-le-ssl.conf
Sources
- https://en.wikipedia.org/wiki/Nextcloud
- https://stackoverflow.com/questions/24512771/having-trouble-writing-to-a-file-with-php-on-ubuntu
- https://github.com/saadismail/useful-bash-scripts/blob/master/db.sh
- https://stackoverflow.com/questions/33470753/create-mysql-database-and-user-in-bash-script
- https://docs.nextcloud.com/server/13/admin_manual/installation/installation_wizard.html
- https://www.techrepublic.com/article/how-to-install-nextcloud-12-on-ubuntu-server/
- https://www.marksei.com/how-to-install-nextcloud-13-on-ubuntu/
- https://www.howtoforge.com/tutorial/how-to-integrate-onlyoffice-with-nextcloud/
- https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
- https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-nextcloud-on-ubuntu-16-04

