{"id":5694,"date":"2021-04-19T08:50:56","date_gmt":"2021-04-19T08:50:56","guid":{"rendered":"https:\/\/linuxways.net\/?p=5694"},"modified":"2022-07-22T18:28:45","modified_gmt":"2022-07-22T18:28:45","slug":"how-to-install-nextcloud-on-ubuntu-20-04-with-apache","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-nextcloud-on-ubuntu-20-04-with-apache\/","title":{"rendered":"How to Install NextCloud on Ubuntu 20.04 with Apache"},"content":{"rendered":"<p>Written in multiple languages including PHP, Java, JavaScript, and Objective C, Nextcloud is a cross-platform and opensource file hosting\/storage platform that allows you to store, edit and share your files as well as manage other utilities such as calendars, notes, maps, and TODOs just to mention a few. . NextCloud provides reliable self-hosted cloud services and comes off as a good substitute for platforms such as Box and DropBox.<\/p>\n<p>Let\u2019s check out how to install NextCloud on Ubuntu 20.04 Focal Fossa.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>Before we start out, ensure you have the following requirements:<\/p>\n<p>An instance of Ubuntu 20.04<\/p>\n<p>A regular user in the system configured with sudo privileges.<\/p>\n<h2><strong>Step 1: Install LAMP server<\/strong><\/h2>\n<p>Nextcloud is predominantly written in PHP and is accessed on the frontend from a browser. The first step dictates that we install the LAMP server before jumping into anything else. LAMP is an acronym that includes Apache, which is a web server, MySQL or MariaDB database engines, and PHP scripting language.<\/p>\n<p>To install the LAMP stack we shall run the command shown.<\/p>\n<pre><strong>$ sudo apt install apache2 libapache2-mod-php php mariadb-server<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"777\" height=\"494\" class=\"wp-image-5695\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-85.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-85.png 777w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-85-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-85-768x488.png 768w\" sizes=\"auto, (max-width: 777px) 100vw, 777px\" \/><\/p>\n<h2><strong>Step 2: Install additional PHP modules<\/strong><\/h2>\n<p>Additional PHP modules are mandatory for Nextcloud installation to proceed. They are quite a number, so invoke the command shown<\/p>\n<pre><strong>$ sudo apt install php-gd php-mysql php-curl php-json php-gmp php-bcmath php-xml php-mbstring php-intl php-imagick php-zip bzip2<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"813\" height=\"475\" class=\"wp-image-5696\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-86.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-86.png 813w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-86-300x175.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-86-768x449.png 768w\" sizes=\"auto, (max-width: 813px) 100vw, 813px\" \/><\/strong><\/p>\n<p>We need to make a few tweaks to the<strong> php.ini <\/strong>file which contains the PHP settings or configurations.<\/p>\n<pre><strong>$ sudo vim \/etc\/php\/7.4\/apache2\/php.ini<\/strong><\/pre>\n<p>First, set the memory limit from the default value to 512M as shown in the screenshot below.<\/p>\n<pre><strong>memory_limit = 512M<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"203\" class=\"wp-image-5697\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-87.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-87.png 614w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-87-300x99.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/p>\n<p>Also, set your timezone. For instance <strong>America\/Denver<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"140\" class=\"wp-image-5698\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-88.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-88.png 679w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-88-300x62.png 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/strong><\/p>\n<p>Now, restart the Apache webserver for the changes to be applied:<\/p>\n<pre><strong>$ sudo systemctl restart apache2<\/strong><\/pre>\n<p>It would also be prudent to confirm that the webserver is up and running as shown.<\/p>\n<pre><strong>$ sudo systemctl status apache2<\/strong><\/pre>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"435\" class=\"wp-image-5699\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-89.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-89.png 812w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-89-300x161.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-89-768x411.png 768w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/h2>\n<h2><strong>Step 3:Create a database for NextCloud<\/strong><\/h2>\n<p>It\u2019s crucial to create a database for Nextcloud\u2019s files and other data that will be saved post-installation. So, access the MariaDB database engine as shown:<\/p>\n<pre><strong>$ sudo mysql -u root -p<\/strong><\/pre>\n<p>Next, proceed and create the database and database user and assign the required privileges as provided in the commands below<\/p>\n<pre><strong>CREATE DATABASE nextcloud_db;<\/strong><\/pre>\n<pre><strong>GRANT ALL ON nextcloud_db.* to 'nextcloud_user'@'localhost' IDENTIFIED BY 'userpassword';<\/strong><\/pre>\n<p>Save the changes to the database engine<\/p>\n<pre><strong>FLUSH PRIVILEGES;<\/strong><\/pre>\n<p>And finally exit.<\/p>\n<pre><strong>EXIT<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"492\" class=\"wp-image-5700\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-90.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-90.png 1003w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-90-300x147.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-90-768x377.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/p>\n<p>The database is now configured. We are then going to download and configure NextCloud.<\/p>\n<h2><strong>Step 4: Download and configure NextCloud<\/strong><\/h2>\n<p>NextCloud provides various installation methods such as running NextCloud as a virtual machine, or as a docker image. However, we are going to install NextCloud manually.<\/p>\n<p>We are going to grab the latest NextCloud zip file from <a href=\"https:\/\/nextcloud.com\/install\/#instructions-server\">NextCloud\u2019s official site<\/a>. At this point, the latest version in NextCloud 21.0.1<\/p>\n<pre><strong>$ wget https:\/\/download.nextcloud.com\/server\/releases\/nextcloud-21.0.1.zip<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"311\" class=\"wp-image-5701\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-91.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-91.png 1000w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-91-300x93.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-91-768x239.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p>Once the NextCloud zip file is complete, unzip the file in the<strong> \/var\/www\/html <\/strong>path.<\/p>\n<pre><strong>$ sudo unzip nextcloud-21.0.1.zip -d \/var\/www\/html\/<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"997\" height=\"125\" class=\"wp-image-5702\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-92.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-92.png 997w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-92-300x38.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-92-768x96.png 768w\" sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/p>\n<p>Thereafter, set the directory permissions to www-data user and group as shown.<\/p>\n<pre><strong>$ sudo chown -R www-data:www-data \/var\/www\/html\/nextcloud<\/strong><\/pre>\n<p>Once that is done, consider setting up the permissions as shown to give the read and execute permissions to the global users.<\/p>\n<pre><strong>$ sudo chmod -R 775 \/var\/www\/html\/nextcloud<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"223\" class=\"wp-image-5703\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-93.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-93.png 1002w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-93-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-93-768x171.png 768w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/p>\n<p>Perfect! Let\u2019s proceed and define a configuration file for NextCloud.<\/p>\n<h2><strong>Step 5: Create a configuration file for NextCloud<\/strong><\/h2>\n<p>Next, we are going to define a configuration file that acts as a virtual host file for NextCloud. So, proceed and create a <strong>nextcloud.conf <\/strong>configuration file as follows.<\/p>\n<pre><strong>$ sudo vim \/etc\/apache2\/sites-available\/nextcloud.conf<\/strong><\/pre>\n<p>Add the lines shown below. For the <strong>ServerName<\/strong> attribute, provide the FQDN of your server or IP address if you don\u2019t have a domain name pointing to your IP.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"484\" class=\"wp-image-5704\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-94.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-94.png 688w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-94-300x211.png 300w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/p>\n<p>Save and exit the virtual host config file. Then enable it as follows.<\/p>\n<pre><strong>$ sudo a2ensite nextcloud.conf<\/strong><\/pre>\n<p>Additionally, enable the Apache webserver modules that will be required later on.<\/p>\n<pre><strong>$ sudo a2enmod rewrite headers dir mime env setenvif ssl<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"469\" class=\"wp-image-5705\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-95.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-95.png 1001w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-95-300x141.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-95-768x360.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/p>\n<p>Lastly, reload the Apache webserver.<\/p>\n<pre><strong>$ sudo systemctl reload apache2<\/strong><\/pre>\n<h2><strong>Step 5: Complete the NextCloud setup <\/strong><\/h2>\n<p>At this point, we have concluded all the configurations. To wind up on the NextCloud setup, open your browser and head to the URL indicated.<\/p>\n<pre><a href=\"http:\/\/server-ip\/nextcloud\"><strong>http:\/\/server-IP\/nextcloud<\/strong><\/a><\/pre>\n<p>You will be required to provide your login and database details as demonstrated in the snippets below.<\/p>\n<h2><strong><img loading=\"lazy\" decoding=\"async\" width=\"447\" height=\"277\" class=\"wp-image-5706\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-96.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-96.png 447w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-96-300x186.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"495\" class=\"wp-image-5707\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-97.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-97.png 505w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-97-300x294.png 300w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/p>\n<p>The finally hit the \u2018<strong>Finish setup<\/strong>\u2019 button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"335\" class=\"wp-image-5708\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-98.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-98.png 469w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-98-300x214.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/p>\n<p>You will be given a walk-through of the preliminary steps that you need to take<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1022\" height=\"495\" class=\"wp-image-5709\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-99.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-99.png 1022w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-99-300x145.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-99-768x372.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-99-1020x495.png 1020w\" sizes=\"auto, (max-width: 1022px) 100vw, 1022px\" \/><\/p>\n<p>And finally, the NextCloud dashboard will be displayed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"433\" class=\"wp-image-5710\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image.jpeg 770w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-300x169.jpeg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-768x432.jpeg 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>You can now upload your files and collaborate with your team members on NextCloud.<\/p>","protected":false},"excerpt":{"rendered":"<p>Written in multiple languages including PHP, Java, JavaScript, and Objective C, Nextcloud is a cross-platform and opensource file hosting\/storage platform that allows you to store, edit and share&hellip;<\/p>","protected":false},"author":1,"featured_media":5836,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[52,266,100],"class_list":["post-5694","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-apache-web-server","tag-nextcloud","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=5694"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5694\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/5836"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=5694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=5694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=5694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}