Ask Ubuntu Asked by MarGraz on November 26, 2021
I haven’t found an official guide to install Nextcloud 19 on Ubuntu 20.04 without using snap.
Here I made a guide on how to install Nextcloud 19 without snap on Ubuntu Server 20.04 (click the link to see the entire guide).
1. Install a clean version of Ubuntu Server 20.04
2. Open a terminal and execute these commands to update your system:
sudo apt-get update
sudo apt-get updgrade
3. This installs the packages for the Nextcloud core system:
sudo apt-get install apache2 mariadb-server libapache2-mod-php7.4
sudo apt-get install php7.4-gd php7.4-json php7.4-mysql php7.4-curl php7.4-mbstring
sudo apt-get install php7.4-intl php-imagick php7.4-xml php7.4-zip
4. Run these commands to disable Apache 2 directory listing
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf
5. It is necessary to secure and configure our "mariadb-server". From terminal, these commands will start the settings and the script will prompt you some questions, you can answer "yes" to all questions, and also create a new root DB user:
sudo mysql_secure_installation
Enter current password for root (enter for none): press Enter
Set root password? [Y/n]: Y
New password: Enter password (this is the MariaDB root password that MUST be different from system root password)
Re-enter new password: Repeat password
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
6. Restart MariaDB
sudo systemctl restart mariadb.service
7. Login MariaDB server
sudo mysql -u root -p
8. Create a new database, you can choose a name (pay attention, semicolon at the end of a command is important). Attention: don't copy and paste directly this command inside the terminal using mouse wheel, because it will be executed immediately, instead use CTRL + SHIFT + V!
CREATE DATABASE choose_a_db_name_here;
At every succeeded operation you will see:
Query OK, 1 rows affected (0.00 sec)
9. Create a DB user and password
CREATE USER 'choose_your_db_username_here'@'localhost' IDENTIFIED BY 'password_here';
10. Then you need to grant the user full access to the database
GRANT ALL ON database_name_chosen_before.* TO 'username_chosen_before'@'localhost' IDENTIFIED BY 'user_password_chosen_before' WITH GRANT OPTION;
11. Save changes and exit from MariaDB
FLUSH PRIVILEGES;
EXIT;
12. Edit php.ini files to change some default settings
sudo nano /etc/php/7.4/apache2/php.ini
Press "CTRL + W", search and change the following lines below and save php.ini. You can find here a list of timezones
file_uploads = On
allow_url_fopen = On
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 600M <-- Use always a size that is a bit more of "upload_max_filesize"
max_execution_time = 300
display_errors = Off
date.timezone = use_your_timezone e.g. Europe/Rome (remove the ';' at the row beginning)
13. It's time to download the NextCloud latest release from the official repository, unzip it, and move the unzipped folder to the Apache2 "html" folder:
cd /tmp && wget https://download.nextcloud.com/server/releases/nextcloud-19.0.0.zip
unzip nextcloud-19.0.0.zip
sudo mv nextcloud /var/www/nextcloud/
Choose to execute 14.1 OR 14.2:
14.1. If you want to install the "data" folder in the root partition - / -, probably in this case you will not have enough space, run the commands below to set the correct permissions:
sudo chown -R www-data:www-data /var/www/nextcloud/
sudo chmod -R 755 /var/www/nextcloud/
14.2. If you prefer to install the "data" folder in the "/home" partition, where you probably have more space, create a folder in "/home", you can call it "clouddata", and then run the commands below to set the correct permissions:
sudo mkdir /home/clouddata/
sudo chown -R www-data:www-data /home/clouddata/
sudo chown -R www-data:www-data /var/www/nextcloud/
sudo chmod -R 755 /var/www/nextcloud/
15. Configure Apahce 2 site configuration file for NextCloud. This file will control how users access the NextCloud content. Run the commands below to create a new configuration file called "nextcloud.conf"
sudo nano /etc/apache2/sites-available/nextcloud.conf
Then copy and paste the content below into the file and save it. Replace the "ServerName" and "ServerAlias" line with your own domain name and directory root location, save the file and exit
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/nextcloud/
ServerName example.com
ServerAlias www.example.com
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
16. Now configure the VirtualHost by running the commands below
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
17. To load all the settings above, restart Apache 2
sudo systemctl restart apache2.service
18. Open your browser and browse the server domain name that you specified before: "example.com". You should see NextCloud setup wizard to complete the installation.
Note: to reach your home server from internet, if you are using your domain name (example.com), probably you need to configure the "A" record type value from your domain vendor administration panel, binding your public IP with the domain name. If your ISP gives you only a set of dynamic public IPs, you can use a free DDNS service to auto update your public IP every time that your modem will restart. There are some free DDNS services that don't require you to confirm your account every month. From your modem router configuration panel you also need to allow traffic through ports 80 (HTTP) and 443 (HTTPS).
18.1. In the "Create an admin account" area, create a valid admin username and password;
18.2. In the "Data Folder" area, specify the path to the "data folder" - you have chosen it at point 14.1 or 14.2 of this guide;
18.3. In the "Configure the database" area, specify the database name and account, you have chosen it at point 8 and 9 of this guide, and click Finish setup;
19. Try to reach your domain name "www.example.com" via browser, probably you will obtain the message "Access through untrusted domain". If you have obtained this error, you need to modify the "config.php" file in "/var/www/nextcloud/config" folder:
sudo nano /var/www/nextcloud/config/config.php
Via nano editor check all the parts highlighted with arrows:
<?php
$CONFIG = array (
'instanceid' => 'here you will see a unique id',
'passwordsalt' => 'here you will see password',
'secret' => 'here you will see a secret key',
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'example.com', <---------- CHECK YOUR DOMAIN HERE
),
'datadirectory' => '/home/clouddata', <---------- CHECK YOUR DATA DIRECTORY HERE (we chose it at point 14.x)
'dbtype' => 'mysql',
'version' => '19.0.0.12',
'overwrite.cli.url' => 'http://example.com/nextcloud', <---------- CHECK YOUR DOMAIN HERE
'dbname' => 'next_db',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'here you will see the DB username',
'dbpassword' => 'here you will see the DB password',
'installed' => true,
);
20. You’re done.
Click the link to see the entire guide: Nextcloud 19 without snap on Ubuntu Server 20.04
Answered by MarGraz on November 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP