Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 25

Gareth Eaton, 06/06/2023 10:52 AM

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