Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 57

Gareth Eaton, 08/17/2024 07:05 AM

1 1 Gareth Eaton
h1. Install on Ubuntu 2204
2
3 57 Gareth Eaton
h2. Installation Instructions
4
5
This is an easy to use install script
6
7
*Step 1: Install Git*
8
First, make sure Git is installed on your server. If it’s not installed, you can install it with the following command:
9
10
sudo apt update
11
sudo apt install git -y
12
13
14
15
*Step 2: Clone the Repository and Run the Installer*
16
After installing Git, follow these steps to install Nextcloud:
17
18
git clone https://gitlab.lightningcr.com/installers/next-cloud-installer.git
19
cd next-cloud-installer
20
chmod +x install_nextcloud.sh
21
sudo ./install_nextcloud.sh
22
23
24
25
26
h2. *If you prefer not to use the script*
27
28
29 43 Gareth Eaton
<pre>
30 26 Gareth Eaton
h1. Install on Ubuntu 20.04 / 22.10
31 43 Gareth Eaton
</pre>
32 1 Gareth Eaton
h2. Requirements
33
34 26 Gareth Eaton
* A server running Ubuntu 20.04.
35 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
36 1 Gareth Eaton
* A root password is configured on your server.
37 43 Gareth Eaton
38
* install software-properties-common
39
40
<pre>
41
sudo apt update
42
sudo apt install software-properties-common
43
</pre>
44
45
After successfully installing software-properties-common, you can add the PHP PPA as follows:
46
47
<pre>
48 49 Gareth Eaton
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
49
sudo apt-get update
50 43 Gareth Eaton
</pre>
51
52 1 Gareth Eaton
53
Before starting, LAMP stack must be installed on your server. If not installed, you can install it with the following command:
54 13 Gareth Eaton
55 28 Gareth Eaton
NOTE: If you are installing Nextcloud 26 + on Ubuntu 20.04, you will need php8, this so use this LAMP stack 
56 13 Gareth Eaton
<pre>
57 56 Gareth Eaton
sudo apt install apache2 mariadb-server php8.1 php8.1-cli php8.1-fpm php8.1-intl php8.1-imagick php8.1-pdo php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath libapache2-mod-php8.1 php8.1-gmp -y
58 42 Gareth Eaton
59 52 Gareth Eaton
60 13 Gareth Eaton
</pre>
61
62 53 Gareth Eaton
NOTE: to use 8.3 php install the following...
63 51 Gareth Eaton
64 1 Gareth Eaton
<pre>
65 52 Gareth Eaton
sudo apt install apache2 mariadb-server php8.3 php8.3-cli php8.3-fpm php8.3-intl php8.3-imagick php8.3-pdo php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath libapache2-mod-php8.3 -y
66
67
sudo apt-get install librsvg2-bin
68 1 Gareth Eaton
sudo apt-get install --reinstall php-imagick
69 53 Gareth Eaton
</pre>
70 1 Gareth Eaton
71 53 Gareth Eaton
if you have installed 8.1 you can remove it using this...
72 1 Gareth Eaton
73 53 Gareth Eaton
<pre>
74
sudo apt-get remove libapache2-mod-php8.1 php8.1 php8.1-bcmath php8.1-cli php8.1-common php8.1-curl php8.1-fpm php8.1-gd php8.1-gmp php8.1-imagick php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-zip
75
76
sudo apt-get autoremove
77
sudo systemctl restart apache2
78 51 Gareth Eaton
</pre>
79
80 1 Gareth Eaton
After installing all packages, edit the PHP configuration file and change some default settings:
81
82 14 Gareth Eaton
Use php -v to check which php is installed, and change the #.# with the right numbers
83 46 Gareth Eaton
in my case it say, *PHP 8.1*
84 13 Gareth Eaton
85 1 Gareth Eaton
<pre>
86 54 Gareth Eaton
nano /etc/php/8.1/apache2/php.ini
87 1 Gareth Eaton
</pre>
88
89
Change the following lines:
90
91
<pre>
92 14 Gareth Eaton
date.timezone = UTC or what ever time zone you are in
93 1 Gareth Eaton
memory_limit = 512M
94
upload_max_filesize = 500M
95
post_max_size = 500M
96
max_execution_time = 300
97 55 Gareth Eaton
opcache.interned_strings_buffer=16
98 1 Gareth Eaton
</pre>
99
100 29 Gareth Eaton
101 40 Gareth Eaton
Note: https://www.php.net/manual/en/timezones.php
102
103 1 Gareth Eaton
Save and close the file then restart the Apache service to apply the changes:
104
105
<pre>
106
systemctl restart apache2
107
</pre>
108
109
&nbsp;
110
111
h2. Create a Database for Nextcloud
112
113
114
---
115
116
Nextcloud uses a MariaDB database as a database backend so you will need to create a database and user in MariaDB.
117
118
First, connect to the MariaDB shell with the following command:
119
120
<pre>
121
mysql
122
</pre>
123
124
Once you are connected to the MariaDB, create a database and user with the following command:
125
126 20 Gareth Eaton
*NOTE: Change the 'password' to the password you would like to use.*
127
128 1 Gareth Eaton
<pre>
129
CREATE DATABASE nextcloud;
130
CREATE USER 'nextcloud'@'localhost' identified by 'password';
131
</pre>
132
133
Next, grant all the privileges to the Nextcloud database with the following command:
134
135
<pre>
136
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
137
</pre>
138
Next, flush the privileges and exit from the MariaDB with the following command:
139
<pre>
140
FLUSH PRIVILEGES;
141
QUIT;
142
</pre>
143
144
&nbsp;
145
146
h2. Download Nextcloud
147
148
---
149
150 50 Gareth Eaton
At the time of of updateing this article, the latest version of Nextcloud is -26.0.2.-  It is now nextcloud-28.0.0.zip - You can download it with the following command:
151 15 Gareth Eaton
*NOTE: you can go to  https://download.nextcloud.com/server/releases/ to check which is the latest version*
152 1 Gareth Eaton
153
<pre>
154 50 Gareth Eaton
wget https://download.nextcloud.com/server/releases/nextcloud-28.0.0.zip
155 1 Gareth Eaton
</pre>
156
157
Once the download is completed, unzip the downloaded file with the following command:
158
159 47 Gareth Eaton
160
161 1 Gareth Eaton
<pre>
162 48 Gareth Eaton
apt install unzip
163 50 Gareth Eaton
unzip nextcloud-28.0.0.zip
164 1 Gareth Eaton
</pre>
165
166
167
Next, move the extracted directory to the Apache web root with the following command:
168
169
<pre>
170
mv nextcloud /var/www/html/
171
</pre>
172
173
Next, change the ownership and permission of the Nextcloud directory using the following command:
174
175
<pre>
176
chown -R www-data:www-data /var/www/html/nextcloud
177
chmod -R 775 /var/www/html/nextcloud
178
</pre>
179
180
&nbsp;
181
182
h2. Create an Apache Virtual Host for Nextcloud
183
184
---
185
186
Next, you will need to create an Apache virtual host configuration file for Nextcloud. You can create it with the following command:
187
<pre>
188
nano /etc/apache2/sites-available/next.conf
189
</pre>
190
191
Add the following lines:
192
193 17 Gareth Eaton
*NOTE: Change the admin@example.com and next.example.com, to the right one for you*
194 16 Gareth Eaton
195 1 Gareth Eaton
<pre>
196
<VirtualHost *:80>
197
     ServerAdmin admin@example.com
198
     DocumentRoot /var/www/html/nextcloud
199
     ServerName next.example.com
200
     ErrorLog /var/log/apache2/nextcloud-error.log
201
     CustomLog /var/log/apache2/nextcloud-access.log combined
202
 
203
    <Directory /var/www/html/nextcloud>
204
	Options +FollowSymlinks
205
	AllowOverride All
206
        Require all granted
207
 	SetEnv HOME /var/www/html/nextcloud
208
 	SetEnv HTTP_HOME /var/www/html/nextcloud
209
 	<IfModule mod_dav.c>
210
  	  Dav off
211
        </IfModule>
212
    </Directory>
213
</VirtualHost>
214
</pre>
215
216
Save and close the file then activate the Apache virtual host and other required Apache modules with the following command:
217
218
<pre>
219
a2ensite next
220
a2enmod rewrite dir mime env headers
221
</pre>
222
223
Next, restart the Apache service to apply the changes:
224
225
<pre>
226
systemctl restart apache2
227
</pre>
228
229 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.
230
231
<pre>
232
sudo a2dissite 000-default.conf
233
service apache2 reload
234
</pre>
235
236 1 Gareth Eaton
&nbsp;
237 3 Gareth Eaton
238 33 Gareth Eaton
239 19 Gareth Eaton
Now in a web-browser go to your nextcloud address(http://next.example.com) and finish the install,  
240 1 Gareth Eaton
241 19 Gareth Eaton
Set up an admin user account, and  for the database it should be,
242
243 18 Gareth Eaton
<pre>
244
Database user: nextcloud
245
Database password: what ever you used
246
Database name: nextcloud
247
Database hose:localhost
248
</pre>
249 22 Gareth Eaton
250 18 Gareth Eaton
---
251 3 Gareth Eaton
252 35 Gareth Eaton
[["Adding default phone region to Nextcloud config file for validating phone numbers in profile settings."]]
253
254
---
255
256 23 Gareth Eaton
The install should now be complete.
257
258 21 Gareth Eaton
---
259 37 Gareth Eaton
260 36 Gareth Eaton
[["Configure a Memcache for Better Performance in Nextcloud"]]
261 1 Gareth Eaton
262 36 Gareth Eaton
---
263 38 Gareth Eaton
264 24 Gareth Eaton
Depending on how you setup your network and server you might have to install a SSL more information on how to do that below.
265 1 Gareth Eaton
266 24 Gareth Eaton
You should also go to "Administration Settings" and in the Overview tab, see the  Security & setup warning, see https://lightningcr.com/projects/nextcloud/wiki to help you with each warning you get.
267 23 Gareth Eaton
268 24 Gareth Eaton
also setup your Email Server,  this is found in Basic setting, again see https://lightningcr.com/projects/nextcloud/wiki to help you with this.
269 21 Gareth Eaton
270
---
271
272 3 Gareth Eaton
h3. [[Installing SSL with Let's Encrypt SSL]]
273 4 Gareth Eaton
[[Installing on with a Nginx with a reverse proxy using a Nginx Proxy Manager]]