Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 39

Gareth Eaton, 06/06/2023 11:51 AM

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