Comments on How to Install Nextcloud with Nginx and Let's Encrypt SSL on Ubuntu 20.04 LTS
In this tutorial, we will show you how to install and configure the latest Nextcloud 18 release on an Ubuntu 20.04 server. We will run Nextcloud with an Nginx web server and PHP7.4-FPM and use MariaDB server (a MySQL fork) as the database system. Nextcloud is a free (Open Source) Dropbox-like software, a fork of the ownCloud project.
21 Comment(s)
Comments
Hello,
thanks for the tutorial. I followed it to install Nextcloud on a Debian server. It seems to have worked so far, I can get to the Nextcloud startpage, but then I get an error when I enter the credentials for the MariaDb:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'nextclouduser'@'localhost' to database 'nextcloud_db'
The user credentials seem to be correct, though, I can log in to the MariaDB as nextclouduser from the command line, so it does not just seem to be a typo when creating the database or user. Do you have any idea what it could be? Do I need to specify a port for localhost?
Any help would be greatly appreciated,
thanks
Try to change the grant command options as below.
grant all privileges on nextcloud_db.* to nextclouduser@localhost with grant optionHello, great guide. I was especially happy about the ready made nginx config since I needed a fast solution and didn't want to work long on that.
There is only one issue I see with your guide: You are using php 7.4 which isn't officially supported by nextcloud (see: https://portal.nextcloud.com/article/supported-platforms-26.html ). That said it should be fine as a lab setup but since this guide is quite thorough I would imagine that it could be used to set up a production environment where that clould become a big problem.
Thanks
If you see the Nextcloud Server System Requirements, you will get the PHP 7.3 and 7.4 is a recommended version for the latest version of Nextcloud.
https://docs.nextcloud.com/server/19/admin_manual/installation/system_requirements.html#server
Hey, this is an awesome tutorial. The only snags I'm hitting is the "optimization part" on the systems settings overviewpage. I'm getting the following:
There are some warnings regarding your setup.The PHP memory limit is below the recommended value of 512MB. The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ?. No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
I've tried to follow the directions as perscribed by the manuals and searched around to find ways to alleviate the problem, but my attempts haven't been fruitful
I figured it out. In order to help clear out those issues, do the following:- For the php memory limit issue: - sudo nano /etc/php/7.4/fpm/php.ini - set "memory_limit = 512M" (from 128M)
- For the memory cache configuration: - sudo apt install redis-server - Check the version: redis-server -v - Check that it's running: systemctl status redis - If it's not running, do: sudo systemctl start redis-server - Auto start the service on boot: sudo systemctl enable redis-server - Install the PHP extension for Redis to work with Nextcloud: sudo apt install php-redis - Check to see if the extension is enabled: php --ri redis - If not enabled: sudo phpenmod redis - Configure the Nextcloud config file: sudo nano /var/www/nextcloud/config/config.php - Place in the following, in bold, right below the 'loglevel' setting and above the ");" syntax: - 'theme' => '', 'loglevel' => 2, 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ),
); - Check the configuration syntax: sudo nginx -t - If it's all clear restart the services: sudo systemctl restart nginx php7.4-fpm
- The last part on the Strict-Transport-Security was my fault, I didn't get the chance to copy/paste everything. I now have and that works as well.
Hope this helps someone else who may run into these issues!
Hi!
I'm having two problems. The first is with creating a certbot SSL certificate. I'm using a dynamic DNS servie from No-IP. I have the No-Ip client running properly and the server set on the DMZ of my network, however, I get the following error:
zog@anikavf:/etc/nginx/sites-available$ sudo certbot certonly --standalone -d anikavf.ddns.net
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for anikavf.ddns.net
Waiting for verification...
Challenge failed for domain anikavf.ddns.net
http-01 challenge for anikavf.ddns.net
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: anikavf.ddns.net
Type: connection
Detail: Fetching
http://anikavf.ddns.net/.well-known/acme-challenge/0RYP-E7FnofW8nIuLSY_hLzyTJZY9_2MuVWSNBbweCo:
Timeout during connect (likely firewall problem)
To fix these errors, please make sure that your domain name was entered correctly and the DNS A/AAAA record(s) for that domain contain(s) the right IP address. Additionally, please check that your computer has a publicly routable IP address and that no firewalls are preventing the server from communicating with the client. If you're using the webroot plugin, you should also verify that you are serving files from the webroot path you provided.
The other problem is with nginx, where I'm getting the following error:
zog@anikavf:/etc/nginx/sites-available$ sudo nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/nextcloud:1
nginx: configuration file /etc/nginx/nginx.conf test failed
I copied and pasted from the above, changing :cloud.hakase-labs.io" to "anikavf.ddns.net", so I'm not sure why I'm getting the error here.
Any suggestions?
Thanks!
zog
Certbot needs ports 80 and 443 to be open. Certbot said: Timeout during connect (likely firewall problem)
Great stuff :)
For extra peace of mind move the 'data' folder to /var/opt/data/ then run chown -R www-data:www-data /var/opt/data/ Next open \var\www\nextcloud\config\config.php and change line 10 to 'datadirectory' => '/var/opt/data',
Let's encrypt does automatically renew, I have to run systemctl stop nginx certbot renew systemctl start nginx Is it possible to automate renewal?
Nice Howto and work you did!
Question though..
You write
systemctl restart php7.4-fpmsystemctl enable php7.4-fpmIs it possible to use 'php7.3-fpm-nextcloud-webgui' instead of 'php7.3-fpm' => '/run/php/php7.3-fpm-nextcloud-webgui.sock' for this to make it more readable?
If yes, how?
Hi,
I followed your nice tutorial to install Nexcloud on OpenMediaVault 5 (based on Debian)
With Step 6 my standard
/var/www/nextcloud/config/config.php
is empty...
Any idea what the content should be or how to generate that it suites OpenMediaVault 5?
Thanks Muhammad Arul for this great piece of work. Following your explanatory article was easy to install my Nextcloud VM (local IP: 192.168.1.226) on a NAS. I have, however, a conflict that I cannot solve.
I already have an NGINX reverse proxy server installed (local IP: 192.168.1.3) to distribute the traffic to different instances and services of my NAS. Obviously ports 80/443 are forwarded by router to this NGINX RP server, and it is on this server where the certificates for the domains that I already use different NAS services are installed (e.g. music.my-domain.com, file.my-domain.com etc.).
How can I modify the Nextcloud installation (according to your detailed steps) in the part NGINX vHost and certificates installation, taking into account that I must redirect the traffic from the existing NGINX RP server where vHost and certificates will be installed?
Thanks in advance,
Thanks a lot for this tutorial, I followed your steps and it worked perfectely on my Debian 10 server. Best tutorial online and the most comprehensive.
Thank you. It was really helpful.
Hi, the tutorial has worked really well for me all the way but I am facing an issue in the last step...
When I go onto my nextcloud site for the first time, it says Error -
PHP module zip not installed.
Please ask your server administrator to install the module.
PHP module dom not installed.
PHP module XMLWriter not installed. PHP module XMLReader not installed.PHP module libxml not installed.
PHP module mbstring not installed.
PHP module GD not installed.
PHP module SimpleXML not installed.
PHP module cURL not installed.
Can anyone tell me if I'm missing anything? I'm sure I have followed every step properly and I would really appreciate any help :)
The PHP modules get installed in step 2 of the tutorial. rerun the apt command to install them.
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
the above config of the vhost for the Nginx is no longer available! I just updated my Nginx and php8.1-fpm today, and the above code is causing "504 Gateway time-out"!
My nginx version: nginx/1.18.0 (Ubuntu)
PHP version: PHP 8.1.2-1ubuntu2.6
I followed the tutorial and this is what I get (actually, the same as before I reached this page)
404 Not Found nginx/1.18.0 (Ubuntu)
This is very well done, commenting on the 10th April 2023 that PHP on the latest nextcloud version needs a minimum of version 8.0 so when you install these commands just make sure to change the 7.4's to 8.2* or what ever version is current