Install Nextcloud in Ubuntu

Nextcloud – cloud platform for storing files, a branch of the project OwnCloud.

On the test, I will install the latest version of Nextcloud in Ubuntu Server 16.04 LTS (at the time of this writing was 12).
First of all, we will install the necessary components:

sudo apt-get update
sudo apt-get install apache2 mysql-server php libapache2-mod-php php-json php-mysql php-bz2 php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip php-memcache php-bcmath php-gmp

Activate the necessary apache2 modules:

sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo a2enmod setenvif
sudo a2enmod ssl

And restart it to apply the changes:

sudo service apache2 restart

Download Nextcloud:

cd ~
wget --no-check-certificate https://download.nextcloud.com/server/releases/latest.tar.bz2

You can verify the checksums MD5 or SHA256 to make sure that the archive is not damaged:

wget --no-check-certificate https://download.nextcloud.com/server/releases/latest.tar.bz2.md5
wget --no-check-certificate https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256
md5sum -c latest.tar.bz2.md5 < latest.tar.bz2
sha256sum -c latest.tar.bz2.sha256 < latest.tar.bz2

Unzip the archive into the web server directory, set permissions and delete it:

sudo tar -C /var/www -xvjf ~/latest.tar.bz2
sudo chown -R www-data:www-data /var/www/nextcloud/
rm ~/latest.tar.bz2
rm ~/latest.tar.bz2.md5
rm ~/latest.tar.bz2.sha256

Create a web configuration file (in the nano editor, press Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/apache2/sites-available/nextcloud.conf

And for example, add to it:

Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All
 
 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 <IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
 </IfModule>
 
 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud
</Directory>

We activate the configuration as follows:

sudo a2ensite nextcloud

or so:

sudo ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf

Restart apache2:

sudo service apache2 restart

Create mysql user and database:

mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON nextcloud.* TO nextcloud@localhost;
flush privileges;
quit

Open in browser https://HOST/nextcloud/ specify the data and click “Finish installation”.
Standard directory for storing user files /var/www/nextcloud/data.

In the PHP configuration /etc/php5/apache2/php.ini specify date.timezone, other parameters are already specified in the file /var/www/nextcloud/.htaccess
I recommend to configure SSL for secure data transfer.
In the settings nextcloud, in the “Administration” menu you can see additional recommendations for customization.

Nextcloud installation completed.

You can view the version of Nextcloud like this:

cd /var/www/nextcloud
sudo -u www-data php occ -V

Server Status:

sudo -u www-data php occ status

View list of installed applications:

sudo -u www-data php occ app:list

Activation/deactivation of the application:

sudo -u www-data php occ app:enable NAME
sudo -u www-data php occ app:disable NAME

View configuration:

sudo -u www-data php occ config:list
sudo -u www-data php occ config:list --private

Scanning files and updating the cache (must be performed, for example, if data has been added to the user’s directory via FTP or moved within the operating system):

sudo -u www-data php occ files:scan USERNAME
sudo -u www-data php occ files:scan --all
sudo -u www-data php occ files:scan --all --no-interaction --quiet

See my articles:

Leave a comment

Leave a Reply