Project

General

Profile

Install on Ubuntu 2204 2210 » History » Version 17

Gareth Eaton, 06/04/2023 12:53 PM

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