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