Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 4

Gareth Eaton, 02/23/2023 08:04 AM

1 1 Gareth Eaton
h1. Install on Ubuntu 2204
2
3
h2. Requirements
4
5
* A server running Ubuntu 22.04.
6
* A valid domain name pointed to the server IP.
7
* A root password is configured on your server.
8
9
Before starting, LAMP stack must be installed on your server. If not installed, you can install it with the following command:
10
<pre>
11
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
12
</pre>
13
14
After installing all packages, edit the PHP configuration file and change some default settings:
15
<pre>
16
nano /etc/php/8.1/apache2/php.ini
17
</pre>
18
19
Change the following lines:
20
21
<pre>
22
date.timezone = UTC
23
memory_limit = 512M
24
upload_max_filesize = 500M
25
post_max_size = 500M
26
max_execution_time = 300
27
</pre>
28
29
Save and close the file then restart the Apache service to apply the changes:
30
31
<pre>
32
systemctl restart apache2
33
</pre>
34
35
&nbsp;
36
37
h2. Create a Database for Nextcloud
38
39
40
---
41
42
Nextcloud uses a MariaDB database as a database backend so you will need to create a database and user in MariaDB.
43
44
First, connect to the MariaDB shell with the following command:
45
46
<pre>
47
mysql
48
</pre>
49
50
Once you are connected to the MariaDB, create a database and user with the following command:
51
52
<pre>
53
CREATE DATABASE nextcloud;
54
CREATE USER 'nextcloud'@'localhost' identified by 'password';
55
</pre>
56
57
Next, grant all the privileges to the Nextcloud database with the following command:
58
59
<pre>
60
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
61
</pre>
62
Next, flush the privileges and exit from the MariaDB with the following command:
63
<pre>
64
FLUSH PRIVILEGES;
65
QUIT;
66
</pre>
67
68
&nbsp;
69
70
h2. Download Nextcloud
71
72
---
73
74
At the time of writing the article, the latest version of Nextcloud is 24.0.1. You can download it with the following command:
75
76
<pre>
77
wget https://download.nextcloud.com/server/releases/nextcloud-24.0.1.zip
78
</pre>
79
80
Once the download is completed, unzip the downloaded file with the following command:
81
82
<pre>
83
unzip nextcloud-24.0.1.zip
84
</pre>
85
86
87
Next, move the extracted directory to the Apache web root with the following command:
88
89
<pre>
90
mv nextcloud /var/www/html/
91
</pre>
92
93
Next, change the ownership and permission of the Nextcloud directory using the following command:
94
95
<pre>
96
chown -R www-data:www-data /var/www/html/nextcloud
97
chmod -R 775 /var/www/html/nextcloud
98
</pre>
99
100
&nbsp;
101
102
h2. Create an Apache Virtual Host for Nextcloud
103
104
---
105
106
Next, you will need to create an Apache virtual host configuration file for Nextcloud. You can create it with the following command:
107
<pre>
108
nano /etc/apache2/sites-available/next.conf
109
</pre>
110
111
Add the following lines:
112
113
<pre>
114
<VirtualHost *:80>
115
     ServerAdmin admin@example.com
116
     DocumentRoot /var/www/html/nextcloud
117
     ServerName next.example.com
118
     ErrorLog /var/log/apache2/nextcloud-error.log
119
     CustomLog /var/log/apache2/nextcloud-access.log combined
120
 
121
    <Directory /var/www/html/nextcloud>
122
	Options +FollowSymlinks
123
	AllowOverride All
124
        Require all granted
125
 	SetEnv HOME /var/www/html/nextcloud
126
 	SetEnv HTTP_HOME /var/www/html/nextcloud
127
 	<IfModule mod_dav.c>
128
  	  Dav off
129
        </IfModule>
130
    </Directory>
131
</VirtualHost>
132
</pre>
133
134
Save and close the file then activate the Apache virtual host and other required Apache modules with the following command:
135
136
<pre>
137
a2ensite next
138
a2enmod rewrite dir mime env headers
139
</pre>
140
141
Next, restart the Apache service to apply the changes:
142
143
<pre>
144
systemctl restart apache2
145
</pre>
146
147
&nbsp;
148 3 Gareth Eaton
149
---
150
151
h3. [[Installing SSL with Let's Encrypt SSL]]
152 4 Gareth Eaton
[[Installing on with a Nginx with a reverse proxy using a Nginx Proxy Manager]]