Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 53

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