{"id":5384,"date":"2018-07-13T19:28:02","date_gmt":"2018-07-13T15:28:02","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/ubuntu-nginx-nextcloud\/"},"modified":"2018-07-13T19:28:02","modified_gmt":"2018-07-13T15:28:02","slug":"how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts\/","title":{"rendered":"How to Install Nextcloud with Nginx on Ubuntu 18.04 LTS"},"content":{"rendered":"<p>Nextcloud is a free (Open Source) Dropbox-like software, a fork of the ownCloud project. Nextcloud is written in PHP and JavaScript, it supports many database systems such as MySQL\/MariaDB, PostgreSQL, Oracle Database, and SQLite. In order to keep your files synchronized between Desktop and your own server, Nextcloud provides applications for Windows, Linux, and Mac desktops and a mobile app for Android and iOS. Nextcloud is not just a Dropbox clone, it provides additional features like Calendar, Contacts, Schedule tasks, and streaming media with Ampache etc.<\/p>\n<p>In this tutorial, we will show you how to install and configure the latest Nextcloud 13.0.2 release on an Ubuntu 18.04 server. We will run Nextcloud with a Nginx web server and PHP7.1-FPM and use MySQL server as the database system.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>Ubuntu 18.04<\/li>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>Install Nginx Web server<\/li>\n<li>Install and Configure PHP7.1-FPM<\/li>\n<li>Install and Configure MySQL Server<\/li>\n<li>Generate SSL Letsencrypt<\/li>\n<li>Download Nextcloud 13<\/li>\n<li>Configure Nginx Virtual Host for Nextcloud<\/li>\n<li>UFW Firewall Configuration<\/li>\n<li>Nextcloud Post-Installation<\/li>\n<\/ol>\n<h2 id=\"step-install-nginx-web-server\">Step 1 &#8211; Install Nginx Web server<\/h2>\n<p>The first step we will do in this nextcloud guide is to install the Nginx web server. We will be using the Nginx web server instead of Apache web server.<\/p>\n<p>Log in to the server and update the repository, then install Nginx web server using the apt command as shown below.<\/p>\n<p class=\"command\">sudo apt update<br \/>sudo apt install nginx -y<\/p>\n<p>After the installation is complete, start the Nginx service and enable the service to launch every time at system boot using systemctl.<\/p>\n<p class=\"command\">systemctl start nginx<br \/>systemctl enable nginx<\/p>\n<p>The Nginx web server has been installed on Ubuntu 18.04. Check it using the netstat or curl command below.<\/p>\n<p class=\"command\">netstat -plntu<br \/>curl -I localhost<\/p>\n<p>The Nginx web server is now running under Ubuntu on standard HTTP port 80.<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts.png\" alt=\"Install Nginx Web server\" width=\"500\" height=\"365\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-phpfpm\">Step 2 &#8211; Install and Configure PHP7.1-FPM<\/h2>\n<p>In this tutorial, we will be using the PHP7.1-FPM for nextcloud. We will be using PHP7.1-FPM from the PPA repository, so we need to add new PPA repository to our system.<\/p>\n<p>Install the &#8216;software-properties-common&#8217; package and add the &#8216;ondrej PHP&#8217; PPA repository by running the following commands.<\/p>\n<p class=\"command\">sudo apt install software-properties-common -y<br \/>sudo add-apt-repository ppa:ondrej\/php -y<\/p>\n<p><strong>Note:<\/strong><\/p>\n<p>On Ubuntu 18.04, the &#8216;add-apt-repository&#8217; command will automatically update the repository.<\/p>\n<p>Now install PHP7.1 and PHP7.1-FPM with all extensions needed using the single apt command below.<\/p>\n<p class=\"command\">sudo apt install php7.1-fpm php7.1-mcrypt php7.1-curl php7.1-cli php7.1-mysql php7.1-gd php7.1-iconv php7.1-xsl php7.1-json php7.1-intl php-pear php-imagick php7.1-dev php7.1-common php7.1-mbstring php7.1-zip php7.1-soap -y<\/p>\n<p>After the installation is complete, we will configure the php.ini files for php-fpm and php-cli.<\/p>\n<p>Go to the &#8216;\/etc\/php\/7.1&#8217; directory.<\/p>\n<p class=\"command\">cd \/etc\/php\/7.1\/<\/p>\n<p>Edit the php.ini files for php-fpm and php-cli using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a>.<\/p>\n<p class=\"command\">vim fpm\/php.ini<br \/>vim cli\/php.ini<\/p>\n<p>Uncomment the &#8216;date.timezone&#8217; line and change the value with your own timezone.<\/p>\n<pre>date.timezone = Asia\/Jakarta<\/pre>\n<p>Uncomment the &#8216;cgi.fix_pathinfo&#8217; line and change the value to &#8216;0&#8217;.<\/p>\n<pre>cgi.fix_pathinfo=0<\/pre>\n<p>Save and exit.<\/p>\n<p>Next, edit the php-fpm pool configuration &#8216;www.conf&#8217;.<\/p>\n<p class=\"command\">vim fpm\/pool.d\/www.conf<\/p>\n<p>Uncomment those lines below.<\/p>\n<pre>env[HOSTNAME] = $HOSTNAME&#13;\nenv[PATH] = \/usr\/local\/bin:\/usr\/bin:\/bin&#13;\nenv[TMP] = \/tmp&#13;\nenv[TMPDIR] = \/tmp&#13;\nenv[TEMP] = \/tmp<\/pre>\n<p>Save and exit.<\/p>\n<p>Restart the PHP7.1-FPM service and enable it to launch every time on system boot.<\/p>\n<p class=\"command\">systemctl restart php7.1-fpm<br \/>systemctl enable php7.1-fpm<\/p>\n<p>Now check it using the netstat command.<\/p>\n<p class=\"command\">netstat -pl | grep php<\/p>\n<p>And you will get the php-fpm is now running under the sock file &#8216;\/run\/php\/php7.1-fpm.sock&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-1.png\" alt=\"Install PHP\" width=\"500\" height=\"171\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-mysql-server\">Step 3 &#8211; Install and Configure MySQL Server<\/h2>\n<p>In this step, we will install the latest MySQL version and create a new database for the nextcloud installation. The latest version MySQL packages are available on the repository by default.<\/p>\n<p>Install MySQL server latest version using the apt command below.<\/p>\n<p class=\"command\">sudo apt install mysql-server mysql-client -y<\/p>\n<p>After the installation is complete, start the MySQL service and enable it to launch everytime at system boot.<\/p>\n<p class=\"command\">systemctl start mysql<br \/>systemctl enable mysql<\/p>\n<p>Now we will configure the MySQL root password using the &#8216;mysql_secure_installation&#8217; command.<\/p>\n<p>Run the following command.<\/p>\n<p class=\"command\">mysql_secure_installation<\/p>\n<p>At this MySQL 5.8 version, there is a security improvement for the MySQL password policy. You need to choose the password policy &#8211; 0 for the LOW policy, 1 for the MEDIUM policy, and 2 for a STRONG password policy.<\/p>\n<p>For this guide, we will be using the &#8216;MEDIUM&#8217; password policy, and it&#8217;s recommended to use the &#8216;STRONG&#8217; password policy on the production server.<\/p>\n<p>Choose number &#8216;1&#8217; and press Enter, then type your new MySQL &#8216;root&#8217; password.<\/p>\n<p><a class=\"fancybox\" id=\"img-3.1_\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/3.1_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-2.png\" alt=\"Install MySQL\" width=\"500\" height=\"349\" title=\"\"><\/a><\/p>\n<pre>Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y&#13;\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : Y&#13;\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : Y&#13;\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : Y<\/pre>\n<p>And the MySQL root password has been set up.<\/p>\n<p>Next, we will create a new database for nextcloud installation. We will create a new database named &#8216;nextcloud_db&#8217; with the user &#8216;nextclouduser&#8217; and password &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"2b654e535f4847445e4f5e584e591f191a6b\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#8216;.<\/p>\n<p>Login to the MySQL shell as a root user with mysql command.<\/p>\n<p class=\"command\">mysql -u root -p<br \/>TYPE THE MYSQL ROOT PASSWORD<\/p>\n<p>Now create the database and user with the password by running following MySQL queries.<\/p>\n<p class=\"command\">create database nextcloud_db;<br \/>create user <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"4d232835392e21223829383e283f0d21222e2c2125223e39\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a> identified by &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"054b607d7166696a70617076607731373445\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#8216;;<br \/>grant all privileges on nextcloud_db.* to <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"48262d303c2b24273d2c3d3b2d3a0824272b292420273b3c\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a> identified by &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"29674c515d4a45465c4d5c5a4c5b1d1b1869\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#8216;;<br \/>flush privileges;<\/p>\n<p>And the new database and user for the nextcloud installation has been created.<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-3.png\" alt=\"Configure MySQL database\" width=\"500\" height=\"364\" title=\"\"><\/a><\/p>\n<p>The MySQL installation and configuration for nextcloud has been completed.<\/p>\n<h2 id=\"step-generate-ssl-letsencrypt\">Step 4 &#8211; Generate SSL Letsencrypt<\/h2>\n<p>In this tutorial, we will secure nextcloud using free SSL from Letsencrypt, and we will generate certificates files using the letsencrypt tool.<\/p>\n<p>If you do not have a domain name or install nextcloud on the local computer, you can generate the Self-Signed certificate using OpenSSL.<\/p>\n<p>Install the &#8216;letsencrypt&#8217; tool using the apt command below.<\/p>\n<p class=\"command\">sudo apt install letsencrypt -y<\/p>\n<p>After the installation is complete, stop the nginx service.<\/p>\n<p class=\"command\">systemctl stop nginx<\/p>\n<p>Next, we will generate the SSL certificates for our domain name &#8216;nextcloud.hakase-labs.io&#8217; using the cerbot command line. Run the command below.<\/p>\n<p class=\"command\">certbot certonly &#8211;standalone -d nextcloud.hakase-labs.io<\/p>\n<p>You will be asked for the email address, and it&#8217;s used for the renew notification. For the Letsencrypt TOS agreement, type &#8216;A&#8217; to agree and for the share email address, you can type &#8216;N&#8217; for No.<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-4.png\" alt=\"Generate Let&#039;s encrypt SSL certificate\" width=\"500\" height=\"381\" title=\"\"><\/a><\/p>\n<p>When it&#8217;s complete, you will get the result as shown below.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-5.png\" alt=\"SSL cert created\" width=\"500\" height=\"328\" title=\"\"><\/a><\/p>\n<p>The SSL certificates Letsencrypt for the netxcloud domain name has been generated, all located at the &#8216;\/etc\/letsencrypt\/live\/domain&#8217; directory.<\/p>\n<h2 id=\"step-download-nextcloud\">Step 5 &#8211; Download Nextcloud<\/h2>\n<p>Before downloading the nextcloud source code, make sure the unzip package is installed on the system. If you don&#8217;t have the package, install it using the apt command below.<\/p>\n<p class=\"command\">sudo apt install wget unzip zip -y<\/p>\n<p>Now go to the &#8216;\/var\/www&#8217; directory and download the nextcloud-13.0.2.zip file.<\/p>\n<p class=\"command\">cd \/var\/www\/<br \/>wget https:\/\/download.nextcloud.com\/server\/releases\/nextcloud-13.0.2.zip<\/p>\n<p>Extract the zip file and you will get the &#8216;nextcloud&#8217; directory, then create a new &#8216;data&#8217; directory.<\/p>\n<p class=\"command\">unzip nextcloud-13.0.2.zip<br \/>mkdir -p nextcloud\/data\/<\/p>\n<p>Now change the owner of &#8216;nextcloud&#8217; directory to the &#8216;www-data&#8217; user and group.<\/p>\n<p class=\"command\">chown -R www-data:www-data \/var\/www\/nextcloud\/<\/p>\n<p>Nextcloud has been downloaded under the &#8216;\/var\/www\/nextcloud&#8217; directory, and it will be the web root directory.<\/p>\n<h2 id=\"step-configure-nginx-virtual-host-for-nextcloud\">Step 6 &#8211; Configure Nginx Virtual Host for Nextcloud<\/h2>\n<p>In this step, we will configure the nginx virtual host for nextcloud. We will configure nextcloud to run under the HTTPS connection and will force the HTTP connection automatically to the secure HTTPS connection.<\/p>\n<p>Now go to the &#8216;\/etc\/nginx\/sites-available&#8217; directory and create a new virtual host file &#8216;nextcloud&#8217;.<\/p>\n<p class=\"command\">cd \/etc\/nginx\/sites-available\/<br \/>vim nextcloud<\/p>\n<p>There, paste the following nextcloud virtual host configuration.<\/p>\n<pre>upstream php-handler {&#13; #server 127.0.0.1:9000;&#13; server unix:\/run\/php\/php7.1-fpm.sock;&#13;\n}&#13;\n&#13;\nserver {&#13; listen 80;&#13; listen [::]:80;&#13; server_name nextcloud.hakase-labs.pw;&#13; # enforce https&#13; return 301 https:\/\/$server_name$request_uri;&#13;\n}&#13;\n&#13;\nserver {&#13; listen 443 ssl http2;&#13; listen [::]:443 ssl http2;&#13; server_name nextcloud.hakase-labs.pw;&#13;\n&#13; ssl_certificate \/etc\/letsencrypt\/live\/nextcloud.hakase-labs.pw\/fullchain.pem;&#13; ssl_certificate_key \/etc\/letsencrypt\/live\/nextcloud.hakase-labs.pw\/privkey.pem;&#13;\n&#13; # Add headers to serve security related headers&#13; # Before enabling Strict-Transport-Security headers please read into this&#13; # topic first.&#13; # add_header Strict-Transport-Security \"max-age=15552000;&#13; # includeSubDomains; preload;\";&#13; #&#13; # WARNING: Only add the preload option once you read about&#13; # the consequences in https:\/\/hstspreload.org\/. This option&#13; # will add the domain to a hardcoded list that is shipped&#13; # in all major browsers and getting removed from this list&#13; # could take several months.&#13; add_header X-Content-Type-Options nosniff;&#13; add_header X-XSS-Protection \"1; mode=block\";&#13; add_header X-Robots-Tag none;&#13; add_header X-Download-Options noopen;&#13; add_header X-Permitted-Cross-Domain-Policies none;&#13;\n&#13; # Path to the root of your installation&#13; root \/var\/www\/nextcloud\/;&#13;\n&#13; location = \/robots.txt {&#13; allow all;&#13; log_not_found off;&#13; access_log off;&#13; }&#13;\n&#13; # The following 2 rules are only needed for the user_webfinger app.&#13; # Uncomment it if you're planning to use this app.&#13; #rewrite ^\/.well-known\/host-meta \/public.php?service=host-meta last;&#13; #rewrite ^\/.well-known\/host-meta.json \/public.php?service=host-meta-json&#13; # last;&#13;\n&#13; location = \/.well-known\/carddav {&#13; return 301 $scheme:\/\/$host\/remote.php\/dav;&#13; }&#13; location = \/.well-known\/caldav {&#13; return 301 $scheme:\/\/$host\/remote.php\/dav;&#13; }&#13;\n&#13; # set max upload size&#13; client_max_body_size 512M;&#13; fastcgi_buffers 64 4K;&#13;\n&#13; # Enable gzip but do not remove ETag headers&#13; gzip on;&#13; gzip_vary on;&#13; gzip_comp_level 4;&#13; gzip_min_length 256;&#13; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;&#13; gzip_types application\/atom+xml application\/javascript application\/json application\/ld+json application\/manifest+json application\/rss+xml application\/vnd.geo+json application\/vnd.ms-fontobject application\/x-font-ttf application\/x-web-app-manifest+json application\/xhtml+xml application\/xml font\/opentype image\/bmp image\/svg+xml image\/x-icon text\/cache-manifest text\/css text\/plain text\/vcard text\/vnd.rim.location.xloc text\/vtt text\/x-component text\/x-cross-domain-policy;&#13;\n&#13; # Uncomment if your server is built with the ngx_pagespeed module&#13; # This module is currently not supported.&#13; #pagespeed off;&#13;\n&#13; location \/ {&#13; rewrite ^ \/index.php$uri;&#13; }&#13;\n&#13; location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {&#13; deny all;&#13; }&#13; location ~ ^\/(?:\\.|autotest|occ|issue|indie|db_|console) {&#13; deny all;&#13; }&#13;\n&#13; location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+)\\.php(?:$|\/) {&#13; fastcgi_split_path_info ^(.+\\.php)(\/.*)$;&#13; include fastcgi_params;&#13; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;&#13; fastcgi_param PATH_INFO $fastcgi_path_info;&#13; fastcgi_param HTTPS on;&#13; #Avoid sending the security headers twice&#13; fastcgi_param modHeadersAvailable true;&#13; fastcgi_param front_controller_active true;&#13; fastcgi_pass php-handler;&#13; fastcgi_intercept_errors on;&#13; fastcgi_request_buffering off;&#13; }&#13;\n&#13; location ~ ^\/(?:updater|ocs-provider)(?:$|\/) {&#13; try_files $uri\/ =404;&#13; index index.php;&#13; }&#13;\n&#13; # Adding the cache control header for js and css files&#13; # Make sure it is BELOW the PHP block&#13; location ~ \\.(?:css|js|woff|svg|gif)$ {&#13; try_files $uri \/index.php$uri$is_args$args;&#13; add_header Cache-Control \"public, max-age=15778463\";&#13; # Add headers to serve security related headers (It is intended to&#13; # have those duplicated to the ones above)&#13; # Before enabling Strict-Transport-Security headers please read into&#13; # this topic first.&#13; # add_header Strict-Transport-Security \"max-age=15768000; includeSubDomains; preload;\";&#13; #&#13; # WARNING: Only add the preload option once you read about&#13; # the consequences in https:\/\/hstspreload.org\/. This option&#13; # will add the domain to a hardcoded list that is shipped&#13; # in all major browsers and getting removed from this list&#13; # could take several months.&#13; add_header X-Content-Type-Options nosniff;&#13; add_header X-XSS-Protection \"1; mode=block\";&#13; add_header X-Robots-Tag none;&#13; add_header X-Download-Options noopen;&#13; add_header X-Permitted-Cross-Domain-Policies none;&#13; # Optional: Don't log access to assets&#13; access_log off;&#13; }&#13;\n&#13; location ~ \\.(?:png|html|ttf|ico|jpg|jpeg)$ {&#13; try_files $uri \/index.php$uri$is_args$args;&#13; # Optional: Don't log access to other assets&#13; access_log off;&#13; }&#13;\n}<\/pre>\n<p>Save and exit.<\/p>\n<p>Enable the virtual host and test the configuration, and make sure there is no error.<\/p>\n<p class=\"command\">ln -s \/etc\/nginx\/sites-available\/nextcloud \/etc\/nginx\/sites-enabled\/<br \/>nginx -t<\/p>\n<p>Now restart PHP7.1-FPM service and nginx service using the systemctl command below.<\/p>\n<p class=\"command\">systemctl restart nginx<br \/>systemctl restart php7.1-fpm<\/p>\n<p>The Nginx virtual host configuration for nextcloud has been created.<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-6.png\" alt=\"Configure Nginx for Nextcloud\" width=\"500\" height=\"179\" title=\"\"><\/a><\/p>\n<h2 id=\"step-configure-ufw-firewall\">Step 7 &#8211; Configure UFW Firewall<\/h2>\n<p>In this tutorial, we will turn on the firewall, and we will be using the UFW firewall for Ubuntu.<\/p>\n<p>Enable the ufw firewall.<\/p>\n<p class=\"command\">ufw enable<\/p>\n<p>Type &#8216;y&#8217; and press Enter to start and enable the UFW firewall.<\/p>\n<p>Now add new SSH, HTTP and HTTPS to the UFW firewall list.<\/p>\n<p class=\"command\">ufw allow ssh<\/p>\n<p>ufw allow http<br \/>ufw allow https<\/p>\n<p>Check the allowed list port on the UFW firewall using the command below.<\/p>\n<p class=\"command\">ufw status<\/p>\n<p>And you will get the HTTP port 80 and HTTPS port 443 is on the list.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-7.png\" alt=\"Configure UFW Firewall\" width=\"500\" height=\"336\" title=\"\"><\/a><\/p>\n<h2 id=\"step-nextcloud-postinstallation\">Step 8 &#8211; Nextcloud Post-Installation<\/h2>\n<p>Open your web browser and type the nextcloud URL address.<\/p>\n<p><em><strong>http:\/\/nextcloud.hakase-labs.io\/<\/strong><\/em><\/p>\n<p>And you will be redirected to the secure HTTPS connection.<\/p>\n<p>On the Top page, we need to create the admin user for nextcloud, type the admin user password. On the &#8216;Data folder&#8217; configuration, type the full path of the &#8216;data&#8217; directory &#8216;\/var\/www\/nextcloud\/data&#8217;.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-8.png\" alt=\"Login to nextCloud\" width=\"500\" height=\"280\" title=\"\"><\/a><\/p>\n<p>Scroll the page to the bottom, and you will get the database configuration. Type the database info that we&#8217;ve created in step 3 and then click the &#8216;Finish Setup&#8217; button.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-9.png\" alt=\"Database configuration\" width=\"500\" height=\"286\" title=\"\"><\/a><\/p>\n<p>And after the installation is complete, you will get the Nextcloud Dashboard as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_and_configure_nextcloud_with_nginx_on_ubuntu_1804\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-10.png\" alt=\"Nextcloud dashboard\" width=\"500\" height=\"291\" title=\"\"><\/a><\/p>\n<p>The Nextcloud 13 installation with Nginx web server and MySQL database on Ubuntu 18.04 has been completed successfully.<\/p>\n<h2 id=\"reference\">Reference<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-nginx-nextcloud%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-11.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-nginx-nextcloud%2F&amp;text=How+to+Install+Nextcloud+with+Nginx+on+Ubuntu+18.04+LTS&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-nginx-nextcloud%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-nextcloud-with-nginx-on-ubuntu-18-04-lts-14.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Nextcloud is a free (Open Source) Dropbox-like software, a fork of the ownCloud project. Nextcloud is written in PHP and JavaScript, it supports many database systems such as MySQL\/MariaDB, PostgreSQL, Oracle Database, and SQLite. In order to keep your files synchronized between Desktop and your own server, Nextcloud provides applications for Windows, Linux, and Mac &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5384","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5384"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5384\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}