In this article, we will show you how to install Nextcloud 9 on an Ubuntu 16.04 VPS with MariaDB, PHP-FPM 7.0, and Nginx. Nextcloud is an open-source self-hosted file sync and share application forked from ownCloud. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.
Next, we need to create a database for the Nextcloud installation.
[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE nextcloud;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
4. Install PHP and required PHP modules
To install the latest stable version of PHP version 7.0 and all necessary modules, run:
The following commands will set the PHP memory limit to 512MB, change the values of upload_max_filesize and post_max_size to 200M and set the timezone to UTC.
[user]$ sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/fpm/php.ini
[user]$ sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini
[user]$ sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/" /etc/php/7.0/fpm/php.ini
[user]$ sed -i "s/upload_max_filesize = .*/upload_max_filesize = 200M/" /etc/php/7.0/fpm/php.ini
[user]$ sed -i "s/post_max_size = .*/post_max_size = 200M/" /etc/php/7.0/fpm/php.ini
Add the following environment variables at the end of the PHP-FPM pool file:
[user]$ sudo nginx -t
[user]$ sudo service nginx restart
7. Install Nextcloud 9
Open https://my.nextcloud.com/install.php in your favorite web browser and you should see the Nextcloud 9 install screen. On this page you’ll need to enter the database details you created earlier, Nextcloud 9 admin details and finally click on the Install button.
That’s it. You have successfully installed Nextcloud 9 on your Ubuntu 16.04 VPS. For more information about how to manage your Nextcloud 9 installation, please refer to the official Nextcloud 9 documentation.
Of course you don’t have to Install Nextcloud 9 on Ubuntu 16.04, if you use one of our Nextcloud Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately. For more updates, you can also read our post on How to Install NextCloud 14 on Ubuntu 16.04.
PS. If you liked this post, on how to Install Nextcloud 9 on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
16 thoughts on “Install Nextcloud 9 on Ubuntu 16.04”
It appears something is mis-configured. I can access the server via IP but not by https://my.nextcloud.com/install.php. I just get site cannot be reached.
Please use your own subdomain/domain instead of ‘my.nextcloud.com’. You have to replace all occurrences of ‘my.nextcloud.com’ with your actual domain name.
excellent tutorial! works as expected – just on question:
how to get rid of this message in Admin Section?
The “Strict-Transport-Security” HTTP header is not configured to at least “15552000” seconds. For enhanced security we recommend enabling HSTS as described in our security tips.
This is the first tutorial where I have seen it recommended that users should disable binary logging in mysql/mariadb. For a small home server is there any benefit to having binary logging enabled? Does it help protect from crashes? I know it is a slight performance hit and is mainly used for replication.
When binary logging is enabled, MySQL performance is somewhat slower. But, if binary logging is enabled, MySQL should survive a crash or dirty shutdown and recover on the next start. So, you can enable binary logging if want to play it on the safe side.
All is working very smooth but I have some problems regarding the rooting. I’m using exactyl the same /etc/nginx/sites-available/nextcloud file except the setup for the server_name.
My problem is, if i type in this server name into my browser i get a Access denied page from nextcloud. Why?
I have built up my directory structure exactly the same way as it is denoted inside your tutorial. When I enter server_name/nextcloud everything works fine. But it also works fine independent of what i type after the “/”.
So it also works for example: server_name/abcd
It redirects me then directly to the login prompt of nextcloud.
I’m not an expert regarding setup the nginx hosts…. So i would appreciate every help on this topic.
I has a problem in the step:
Test the Nginx configuration and restart nginx:
[user]$ sudo nginx -t
[user]$ sudo service nginx restart
In my server apper this error:
nginx: [emerg] BIO_new_file(“/etc/nginx/ssl/nextcloud.crt”) failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(‘/etc/nginx/ssl/nextcloud.crt’,’r’) error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
And i try restart the service, but appert this error:
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
I’m check the error in the systemctl and appear:
● nginx.service – A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-01-31 15:50:29 CET; 1min 7s ago
Process: 48046 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 48202 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 47965 (code=exited, status=0/SUCCESS)
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: Starting A high performance web server and a reverse proxy server…
Jan 31 15:50:29 GOLD-CLOUD-002 nginx[48202]: nginx: [emerg] BIO_new_file(“/etc/nginx/ssl/nextcloud.crt”) failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(‘/etc/nginx/ssl/nextcloud.crt’,’r’) error:2006D080:
Jan 31 15:50:29 GOLD-CLOUD-002 nginx[48202]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Unit entered failed state.
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Failed with result ‘exit-code’.
The error message shows you that /etc/nginx/ssl/nextcloud.crt doesn’t exist. You need to edit the Nginx virtual server block and use the correct path to your SSL certificate.
It appears something is mis-configured. I can access the server via IP but not by
https://my.nextcloud.com/install.php
. I just get site cannot be reached.Hi Jon,
Please use your own subdomain/domain instead of ‘my.nextcloud.com’. You have to replace all occurrences of ‘my.nextcloud.com’ with your actual domain name.
Thanks.
I was able to configure it by register with asus ddns
Hi, under which structure can I reach the nextcloud? (local network – e.g. 192.178.1.12/nextcloud)
Thanks in advance.
What exactly do you mean by structure ?
You can use the
hosts
file point a domain to your local machine during development.excellent tutorial! works as expected – just on question:
how to get rid of this message in Admin Section?
The “Strict-Transport-Security” HTTP header is not configured to at least “15552000” seconds. For enhanced security we recommend enabling HSTS as described in our security tips.
To get rid of that message you need to enable HTTP Strict Transport Security. Add this line to your Nginx server block:
You can get more info and instructions at
https://docs.nextcloud.com/server/9/admin_manual/configuration_server/harden_server.html#enable-hsts-label
This is the first tutorial where I have seen it recommended that users should disable binary logging in mysql/mariadb. For a small home server is there any benefit to having binary logging enabled? Does it help protect from crashes? I know it is a slight performance hit and is mainly used for replication.
When binary logging is enabled, MySQL performance is somewhat slower. But, if binary logging is enabled, MySQL should survive a crash or dirty shutdown and recover on the next start. So, you can enable binary logging if want to play it on the safe side.
I have this error
SQLSTATE[HY000] [1045] Access denied for user ‘super’@’localhost’ (using password: YES) What should I do????
Make sure the password for the ‘super’ MySQL user is correct, or check if ‘super’ MySQL user actually exists.
Great tutorial!!!
All is working very smooth but I have some problems regarding the rooting. I’m using exactyl the same /etc/nginx/sites-available/nextcloud file except the setup for the server_name.
My problem is, if i type in this server name into my browser i get a Access denied page from nextcloud. Why?
I have built up my directory structure exactly the same way as it is denoted inside your tutorial. When I enter server_name/nextcloud everything works fine. But it also works fine independent of what i type after the “/”.
So it also works for example: server_name/abcd
It redirects me then directly to the login prompt of nextcloud.
I’m not an expert regarding setup the nginx hosts…. So i would appreciate every help on this topic.
Thanks in advance!!
Thanks a lot, but why do you recommend the PHP setting “cgi.fix_pathinfo=1”?
Afaik it should always be set to “0” or am I mistaken here?
Please see: https://serverfault.com/questions/627903/is-the-php-option-cgi-fix-pathinfo-really-dangerous-with-nginx-php-fpm
I has a problem in the step:
Test the Nginx configuration and restart nginx:
[user]$ sudo nginx -t
[user]$ sudo service nginx restart
In my server apper this error:
nginx: [emerg] BIO_new_file(“/etc/nginx/ssl/nextcloud.crt”) failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(‘/etc/nginx/ssl/nextcloud.crt’,’r’) error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed
And i try restart the service, but appert this error:
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
I’m check the error in the systemctl and appear:
● nginx.service – A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-01-31 15:50:29 CET; 1min 7s ago
Process: 48046 ExecStop=/sbin/start-stop-daemon –quiet –stop –retry QUIT/5 –pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 48202 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 47965 (code=exited, status=0/SUCCESS)
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: Starting A high performance web server and a reverse proxy server…
Jan 31 15:50:29 GOLD-CLOUD-002 nginx[48202]: nginx: [emerg] BIO_new_file(“/etc/nginx/ssl/nextcloud.crt”) failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(‘/etc/nginx/ssl/nextcloud.crt’,’r’) error:2006D080:
Jan 31 15:50:29 GOLD-CLOUD-002 nginx[48202]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Unit entered failed state.
Jan 31 15:50:29 GOLD-CLOUD-002 systemd[1]: nginx.service: Failed with result ‘exit-code’.
Could you helpme please.
Thanks.
The error message shows you that
/etc/nginx/ssl/nextcloud.crt
doesn’t exist. You need to edit the Nginx virtual server block and use the correct path to your SSL certificate.