Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 43

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