Install on Ubuntu 2204 2210 » History » Revision 2
Revision 1 (Gareth Eaton, 02/23/2023 08:00 AM) → Revision 2/57 (Gareth Eaton, 02/23/2023 08:00 AM)
h1. Install on Ubuntu 2204
h2. Requirements
* A server running Ubuntu 22.04.
* A valid domain name pointed to the server IP.
* A root password is configured on your server.
Before starting, LAMP stack must be installed on your server. If not installed, you can install it with the following command:
<pre>
apt install apache2 mariadb-server php php-cli php-fpm php-json php-intl php-imagick php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath apache2 libapache2-mod-php -y
</pre>
After installing all packages, edit the PHP configuration file and change some default settings:
<pre>
nano /etc/php/8.1/apache2/php.ini
</pre>
Change the following lines:
<pre>
date.timezone = UTC
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300
</pre>
Save and close the file then restart the Apache service to apply the changes:
<pre>
systemctl restart apache2
</pre>
h2. Create a Database for Nextcloud
---
Nextcloud uses a MariaDB database as a database backend so you will need to create a database and user in MariaDB.
First, connect to the MariaDB shell with the following command:
<pre>
mysql
</pre>
Once you are connected to the MariaDB, create a database and user with the following command:
<pre>
CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' identified by 'password';
</pre>
Next, grant all the privileges to the Nextcloud database with the following command:
<pre>
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
</pre>
Next, flush the privileges and exit from the MariaDB with the following command:
<pre>
FLUSH PRIVILEGES;
QUIT;
</pre>
h2. Download Nextcloud
---
At the time of writing the article, the latest version of Nextcloud is 24.0.1. You can download it with the following command:
<pre>
wget https://download.nextcloud.com/server/releases/nextcloud-24.0.1.zip
</pre>
Once the download is completed, unzip the downloaded file with the following command:
<pre>
unzip nextcloud-24.0.1.zip
</pre>
Next, move the extracted directory to the Apache web root with the following command:
<pre>
mv nextcloud /var/www/html/
</pre>
Next, change the ownership and permission of the Nextcloud directory using the following command:
<pre>
chown -R www-data:www-data /var/www/html/nextcloud
chmod -R 775 /var/www/html/nextcloud
</pre>
h2. Create an Apache Virtual Host for Nextcloud
---
Next, you will need to create an Apache virtual host configuration file for Nextcloud. You can create it with the following command:
<pre>
nano /etc/apache2/sites-available/next.conf
</pre>
Add the following lines:
<pre>
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/nextcloud
ServerName next.example.com
ErrorLog /var/log/apache2/nextcloud-error.log
CustomLog /var/log/apache2/nextcloud-access.log combined
<Directory /var/www/html/nextcloud>
Options +FollowSymlinks
AllowOverride All
Require all granted
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
</pre>
Save and close the file then activate the Apache virtual host and other required Apache modules with the following command:
<pre>
a2ensite next
a2enmod rewrite dir mime env headers
</pre>
Next, restart the Apache service to apply the changes:
<pre>
systemctl restart apache2
</pre>
h2. Nginx Proxy Manager
---
Add a *A record* pointing to your Nginx Proxy Manager install,
Add a Proxy Hosts, and install SSL Right.
In the custom location,
add the root / directory & /var/www/html/nextcloud/data/
Then in the Advanced tab add the following...
<pre>
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy same-origin;
location /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
location /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
</pre>