Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 52

Gareth Eaton, 12/14/2023 03:16 PM

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