Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 42

Gareth Eaton, 10/15/2023 11:32 PM

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