Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 21

Gareth Eaton, 06/04/2023 01:03 PM

1 1 Gareth Eaton
h1. Install on Ubuntu 2204
2
3
h2. Requirements
4
5
* A server running Ubuntu 22.04.
6 7 Gareth Eaton
* A valid domain name pointed to the server or Nginx Proxy Manager IP.  See "A Record":https://lightningcr.com/projects/dns/wiki/A_record
7 1 Gareth Eaton
* 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 13 Gareth Eaton
11
*NOTE: We have two LAMP stack, depending on wich Next cloud you are going to install*
12
13 1 Gareth Eaton
<pre>
14
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
15
</pre>
16 10 Gareth Eaton
17 13 Gareth Eaton
NOTE: If you are installing next cloud 26 + you will need php8, this so use this LAMP stack 
18
<pre>
19
sudo apt install apache2 mariadb-server php8.0 php8.0-cli php8.0-fpm php8.0-intl php8.0-imagick php8.0-pdo php8.0-mysql php8.0-zip php8.0-gd php8.0-mbstring php8.0-curl php8.0-xml php8.0-bcmath libapache2-mod-php8.0 -y
20
</pre>
21
22 1 Gareth Eaton
After installing all packages, edit the PHP configuration file and change some default settings:
23
24 14 Gareth Eaton
Use php -v to check which php is installed, and change the #.# with the right numbers
25
in my case it say, *PHP 8.0.28*, so I would use 8.0
26 13 Gareth Eaton
27 1 Gareth Eaton
<pre>
28 13 Gareth Eaton
nano /etc/php/#.#/apache2/php.ini
29 1 Gareth Eaton
</pre>
30
31
Change the following lines:
32
33
<pre>
34 14 Gareth Eaton
date.timezone = UTC or what ever time zone you are in
35 1 Gareth Eaton
memory_limit = 512M
36
upload_max_filesize = 500M
37
post_max_size = 500M
38
max_execution_time = 300
39
</pre>
40
41
Save and close the file then restart the Apache service to apply the changes:
42
43
<pre>
44
systemctl restart apache2
45
</pre>
46
47
&nbsp;
48
49
h2. Create a Database for Nextcloud
50
51
52
---
53
54
Nextcloud uses a MariaDB database as a database backend so you will need to create a database and user in MariaDB.
55
56
First, connect to the MariaDB shell with the following command:
57
58
<pre>
59
mysql
60
</pre>
61
62
Once you are connected to the MariaDB, create a database and user with the following command:
63
64 20 Gareth Eaton
*NOTE: Change the 'password' to the password you would like to use.*
65
66 1 Gareth Eaton
<pre>
67
CREATE DATABASE nextcloud;
68
CREATE USER 'nextcloud'@'localhost' identified by 'password';
69
</pre>
70
71
Next, grant all the privileges to the Nextcloud database with the following command:
72
73
<pre>
74
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
75
</pre>
76
Next, flush the privileges and exit from the MariaDB with the following command:
77
<pre>
78
FLUSH PRIVILEGES;
79
QUIT;
80
</pre>
81
82
&nbsp;
83
84
h2. Download Nextcloud
85
86
---
87
88 15 Gareth Eaton
At the time of of updateing this article, the latest version of Nextcloud is 26.0.2. You can download it with the following command:
89
*NOTE: you can go to  https://download.nextcloud.com/server/releases/ to check which is the latest version*
90 1 Gareth Eaton
91
<pre>
92 12 Gareth Eaton
wget https://download.nextcloud.com/server/releases/nextcloud-26.0.2.zip
93 1 Gareth Eaton
</pre>
94
95
Once the download is completed, unzip the downloaded file with the following command:
96
97
<pre>
98 11 Gareth Eaton
unzip nextcloud-26.0.2.zip
99 1 Gareth Eaton
</pre>
100
101
102
Next, move the extracted directory to the Apache web root with the following command:
103
104
<pre>
105
mv nextcloud /var/www/html/
106
</pre>
107
108
Next, change the ownership and permission of the Nextcloud directory using the following command:
109
110
<pre>
111
chown -R www-data:www-data /var/www/html/nextcloud
112
chmod -R 775 /var/www/html/nextcloud
113
</pre>
114
115
&nbsp;
116
117
h2. Create an Apache Virtual Host for Nextcloud
118
119
---
120
121
Next, you will need to create an Apache virtual host configuration file for Nextcloud. You can create it with the following command:
122
<pre>
123
nano /etc/apache2/sites-available/next.conf
124
</pre>
125
126
Add the following lines:
127
128 17 Gareth Eaton
*NOTE: Change the admin@example.com and next.example.com, to the right one for you*
129 16 Gareth Eaton
130 1 Gareth Eaton
<pre>
131
<VirtualHost *:80>
132
     ServerAdmin admin@example.com
133
     DocumentRoot /var/www/html/nextcloud
134
     ServerName next.example.com
135
     ErrorLog /var/log/apache2/nextcloud-error.log
136
     CustomLog /var/log/apache2/nextcloud-access.log combined
137
 
138
    <Directory /var/www/html/nextcloud>
139
	Options +FollowSymlinks
140
	AllowOverride All
141
        Require all granted
142
 	SetEnv HOME /var/www/html/nextcloud
143
 	SetEnv HTTP_HOME /var/www/html/nextcloud
144
 	<IfModule mod_dav.c>
145
  	  Dav off
146
        </IfModule>
147
    </Directory>
148
</VirtualHost>
149
</pre>
150
151
Save and close the file then activate the Apache virtual host and other required Apache modules with the following command:
152
153
<pre>
154
a2ensite next
155
a2enmod rewrite dir mime env headers
156
</pre>
157
158
Next, restart the Apache service to apply the changes:
159
160
<pre>
161
systemctl restart apache2
162
</pre>
163
164 5 Gareth Eaton
NOTE: we have had it where the default site configuration was overriding my vhost configuration, if this happens to you you can disable the default configuration.
165
166
<pre>
167
sudo a2dissite 000-default.conf
168
service apache2 reload
169
</pre>
170
171 1 Gareth Eaton
&nbsp;
172 3 Gareth Eaton
173
---
174 19 Gareth Eaton
Now in a web-browser go to your nextcloud address(http://next.example.com) and finish the install,  
175 1 Gareth Eaton
176 19 Gareth Eaton
Set up an admin user account, and  for the database it should be,
177
178 18 Gareth Eaton
<pre>
179
Database user: nextcloud
180
Database password: what ever you used
181
Database name: nextcloud
182
Database hose:localhost
183
</pre>
184
---
185 3 Gareth Eaton
186 21 Gareth Eaton
---
187
188
---
189
190 3 Gareth Eaton
h3. [[Installing SSL with Let's Encrypt SSL]]
191 4 Gareth Eaton
[[Installing on with a Nginx with a reverse proxy using a Nginx Proxy Manager]]