Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 50

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