Nextcloud: Complete Setup Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] do [Music] hello and welcome back to learn linux tv in today's video i am going to walk you through a full installation of nexcloud on your linux server and your server can be running either debian 10 raspberry pi os or ubuntu 2004 i have actually tested the process on each of those three so if you are running one of those three distributions then you are in good shape in fact there's only one command in this entire process that differs with my approach when it comes to the process for those distributions and i will call that out when we get to it but otherwise the process is exactly the same now before we get into the content though i want to let you guys know about the sponsor for today's video which is actually me i have written a book recently mastering ubuntu server third edition and i just want to get the word out if you haven't already heard you can check it out at ubuntuserverbook.com and welcome you guys through a cloud installation is actually part of that book but now i'm going to do a video version of that in today's video but that's just one of the many topics included in that book so please check it out and if you already have a copy i would really appreciate it if you would leave a review on amazon that would really help me out so now without any further ado let's go ahead and get the process started for installing nexcloud so let's go ahead and walk through the process of setting up nexcloud now first of all i highly recommend that you set up a domain for your next cloud server if you can now if the instance that you plan on installing nexcloud on isn't actually a public-facing instance then you won't be able to map a domain to it unless you set up a proxy which is beyond the scope of this video but if you are using a vps or a server that is public-facing then having a domain would be a great thing to have but i'll leave that up to you on my end i am actually going to show the process of applying a domain to the next cloud instance so if that's something that you want to do you can follow along with that otherwise you can skip this part and just refer to your next cloud server by its ip address that's perfectly fine so now i'm going to walk through the process of setting up a domain i've already purchased one and it's learn linux.tv and well that is the domain for my website so what i'm going to do is add a subdomain here so i will add an a record and for the host name i'm just going to call it nc obviously short for next cloud and then i need to type the ip address of my instance right here now on my end i decided to create a lenode instance and again it doesn't really matter if you are using a virtual machine a vps instance a physical server the instructions are all the same after the domain but lenode is a sponsor of my channel and i really do like their service so it's really easy for me to create a quick instance to use for an example for this video so i'm going to copy the ip address for this particular instance i decided to set it up with ubuntu 2004 again debian 10 and raspberry pi os are fair game as well and here i'm going to paste that ip address into this field and then i will click add record now it's probably going to take about 15 minutes or so for the dns change to propagate it's not actually going to resolve quite yet but that's okay because it's going to take about that long for this process to finish anyway so by the time we get to the point where we are going to add an ssl certificate it should be ready to go so again i have this instance right here i'm going to copy the ip address and then over here on this workspace i'm going to ssh into that instance and i will leave it up to you to make sure that you are typing the correct username and password to get access to your linux instance and i will accept this by answering yes i'll type in the password it might help if i type that correctly and there we go so first what i'm going to do is set the host name to match the domain name that i have chosen for this instance and if you don't actually have a domain name you should still go through this process you can name it something simple like next cloud that's fine there's two files that i want to edit so i will type nano and then i will edit slash etsy slash host name and you might need to use sudo here if you don't actually have access to the root account since i'm logged in as root i don't need sudo for this purpose i'll press enter and currently the host name is simply localhost so i'm going to delete that and then i'm going to type in in my case the fully qualified domain name of nc.learnlinux.tv and again if you don't have a domain then you can simply just type the name of your server whatever you want it to be simplifying it down to next cloud is fine so ctrl o and then enter to save the file and then control x to exit out next i'm going to edit the etsy host file and i'm going to add a new line here and i'm going to make this 127.0.1.1 i'll tab over to keep everything aligned and then i will type the same hostname or domain name here that i typed in the other file and that's what mine is so i will save the file again control o and then enter and then control x to exit out now it's a great idea to make sure that all of the packages on your server are all up to date and for that i will first run app update and again use sudo if you are not logged in as root so i'll press enter and this will refresh the package repository index and it shows that we have eight packages available to be upgraded and to do that we will run apt dist hyphen upgrade and then enter and then i'll press enter again so now we have all of our packages up to date so next let's add a user for ourselves if we don't already have one depending on how you've obtained your linux server or how you have it set up you may already have a local user if you are logged in as root as i am most vps providers actually give you a root account and leave it up to you to create a local user in that case you actually have to create a local user but again if you already have one you should be all set and ready to go and you shouldn't need to do this so i am going to run add user and then i will type the name of the user that i want to create i'll just create it as me my first name i think that's good enough and then i'll type in the password for that user and again and then i'm going to skip all of these prompts right here i'll just keep pressing enter and then enter again and now our new user is created to ensure that our user is able to use sudo we can run user mod a uppercase g sudo and j which is my username just change that for whatever your username happens to be and there we go so now we have a local user we've installed all of the updates and we have also set the hostname as well so what i recommend you do is just simply reboot the server and that's what i'm going to do so i'll press enter and then i will be right back as soon as this is finished so now let's go ahead and ssh back into the server hopefully it's available so i just change the username to mine same ip address and there we go i am now connected to my next cloud server or what will become my next cloud server and i'm logged in as my normal local user so next i recommend that you install tmux and this is optional but i think it's a very good idea so sudo because i'm logged in as a non-root user at this time apt install and then tmux and in my case that was already installed and a full walkthrough of what tmux is is beyond the scope of this video i do have an entire playlist with a tutorial series that will teach you everything you need to know to use tmux already on my channel if you're interested i'll put a card right about here so go ahead and check that out if you want to but the reason why i'm having you install tmux right now is because it gives you a layer of protection that i recommend that you benefit from so i will enter tmux and you can see that we now have this little bar here at the bottom we don't have to worry about exactly what that does quite yet again check out the series if you want to learn more but i'll show you what it actually does so i'm just going to type something and let's just assume that my network connection went down or my internet connection went down and i lost access to my instance i'll simulate that right now and oops i've lost connection to my server and that would really suck if i was in the middle of the installation and maybe getting disconnected from the server at just the right time will cause me to have to start all the way over again that wouldn't be a great thing to experience so i would ssh back into the server and then i could simply run tmux attach just like that and just like that my session is restored so what tmux will allow us to do is keep this running regardless of whether or not we are connected to our server the session will stay alive in the background so next what we're going to do is download the zip file that we will use to install next cloud on our server so for that i'm going to move over to a web browser i have already navigated to the official next cloud site at nextcloud.com and then what i could do is click up here where it says get next cloud i'll go to server packages and then we have the download button right here but we're not going to click it what we're going to do instead is right click on it and then we'll click on copy link location back in the terminal i need to make sure that we have wget installed and in my case i do if i didn't i could run sudo apt install wget just like that but i already have it so i won't need to do that so what i could do is type wget and then i could paste in the url that i copied from the website which in my case is this one as of the time i'm recording this video the current version is 20.0.6 but they are coming out with new versions all the time so don't be surprised if by the time you watch this video that they are up to a newer version so anyway i'll press enter and now we have downloaded nexcloud we can see it right there so now that we've downloaded the install file to our server we have what we need to install next cloud but we're going to come back to that because we need to prepare the server a little bit more first before we get that installed and one of the first requirements that we need to set up is setting up a database server because next cloud needs a database server and for that we can run sudo apt install mariadb hyphen server i'll press enter and then enter again and now we have the mariadb server installed and that's what we're going to use to set up the database that's going to serve as the back end for nexcloud so next i recommend that we set some basic security for the database server nothing too major but we have a dedicated command that we can use so we will run sudo mysql underscore secure underscore installation and even though we've installed the mariadb server the command syntax for the secure installation script still reads my sql but we'll ignore that it does work so i'll press enter and it's going to ask us a series of questions about our installation so that way we can better secure it so first of all it's asking us to enter the current root password and it's not talking about the root password for the linux distribution it's talking about the root password for the database server but we haven't set one so we're just going to press enter for none because there isn't one yet and now it's asking us if we would like to set the root password notice that the y is in caps which means it's the default option if we don't actually choose one or the other i could actually type y and then press enter to answer yes but i'm just going to press enter to accept the default of y less typing and this will allow us to set the root password so i will type in the password that i want the root password for the database server to be and again it's asking me if i would like to remove anonymous users i'll press enter for yes it's asking me if i would like to disallow root login remotely in my opinion i don't even think a database server should ever be remotely available so of course i want to disable any form of remote login that i can so i'll press enter for yes and now it's asking if i would like to remove any test databases and access to test databases and by default it comes with one named test so let's remove it by pressing enter and then enter again to reload the privilege tables which basically just refreshes everything i'll press enter again and we're back to the prompt so next what i'm going to do is run sudo mariadb and you'll notice that the command prompt has completely changed so now i actually have a command prompt to the database server itself so at this point linux commands will not work i need to enter database server commands specifically my sql style commands and if you don't know what commands to use well don't worry because i'm going to walk you through everything so first of all we need to create a database for next cloud so what i'll do is type create and then database and i type that in all caps that's not required but when it comes to database servers it's standard to type the commands in all caps but you don't have to type in all caps but i'm going to follow the best practices here and then we need to give it the name that we want applied to the database that we're creating i'll just call it next cloud clever i know and we're going to end the statement with a semicolon and i'll press enter the database has been created and to see that for ourselves we could type show databases and then of course the semicolon and the statement and we can see the third line down says nextcloud so the database has indeed been created so the next command is fairly long so i'm just going to paste it in right here so essentially what i'm doing is i'm creating a user and that user is called nextcloud and then that user is going to be located at localhost which means the user exists right here on this particular server the line did wrap a bit but i will have all of the commands that i'm using in this video in the official wiki page for this video that i will have linked in the description down below and that user will be identified by a password of my password make sure that you change this make it a good password a randomly generated password if you can and make sure you store it in a safe place because this is going to be the database that next cloud will need to be able to connect to now because this is just a test instance that i will be destroying after i'm done recording the footage i don't really care that the password is simple but on your end i recommend that you create a good password for this so what we're doing is we are granting all privileges literally all privileges on the next cloud database and everything inside the next cloud database to a user named nextcloud that exists here on the local server and is identified by this password right here so again change that password to something good and then press enter so now we will run flush privileges semicolon make sure everything is refreshed and then we can hold ctrl and press d to disconnect from the database server so now we have a database to serve as the back-end database for nexcloud and that's pretty cool so let's continue on with the installation now next cloud requires a web server in order to function and i've decided to install the apache web server it's tried and true it works great so that's what i'm going to show you how to do actually the command to install the packages that we need is quite long because there's quite a few packages that we need so i'm going to paste it in right here and again i have a wiki article linked down below in the description where you can grab these commands for yourself or you can simply pause the video right here if you'd like to jot down these packages now notice that apache is not among the packages that i'm installing here but that's okay because apache should be pulled in as a dependency we'll check that i'll press enter and we can see right here that apache is among the packages that are being installed if for some reason you don't see apache here then make sure you add the apache 2 package along with the others so i'll press enter to accept the defaults it's going to download everything and install all the packages so i'll let it finish and now at this point we should have a web server installed apache in particular and it should already be working and to verify that apache is in fact working you can go over to a browser open a new tab and then just feel free to paste the ip address right here in the address bar and as you can see here apache is working i typed in the ip address for my instance here and we see the apache to default web page your default page may vary depending on which distribution you are using but you should see some sort of default page here and in fact now would be a great time to see whether or not your domain name if you have one has propagated properly and is mapped to this particular server so i'll type it in right here nc.learnlinux.tv in my case and as you can see i get the same page so now i know that the domain is actually working now let's go back to the terminal so let's go ahead and enable some php mods that we need for this to function properly so we will run sudo php and mod and then we will enable bc math gmp imagic and intl and it's beyond the scope of this video to go through those particular extensions and what they do but they do add additional capability to nexcloud and they also make it work better as well so it's a great idea to go ahead and enable those which is exactly what this command will do we didn't receive any output but i wasn't expecting to see anything so we should be good to go there now the default apache web page is well pretty cool but it's not what we want now instead of that default web page i'm sure we would prefer to see next cloud because that's the whole point so let's get that installed now first of all we need the unzip command i could type which and then unzip to see if it's present and it's not so let's go ahead and install that then sudo apt install unzip enter and the reason why we have installed on zip is because the next cloud file that we've downloaded is a zipped file so we will need the unzip utility to extract it and in fact that's exactly what we're going to do right now so we'll type unzip space and then the file name of the next cloud file that we've downloaded i'll press enter it's going to explode it into a bunch of files and now that's extracted so now that we have extracted the next cloud folder from the next cloud zip file we can see it there in blue we should actually rename that now my preference is to rename the next cloud directory to match the domain name it's not required but it's what i like to do keeps everything simple and consistent so i will move the next cloud directory to in my case nc.learnlinux.tv and now we need to change the ownership of that directory so if i run ls-l we can see that it's owned by my user and my group so let's actually change that i'll use sudo and the ch own command will allow me to change the ownership of that directory and everything underneath it and i'm going to add dash capital r which is recursive mode that will ensure that the syntax i'm about to execute will make all of those changes to not only that directory but everything underneath it as well and i will change the owner to www hyphen data that's the apache user that's created automatically when you install the apache package and then colon and again www hyphen data that's the group that i want assigned to that particular directory and then i'm going to give it the name of the next cloud folder as the object i want to change ownership on that should happen pretty quick so ls-l we can see right here that the ownership has indeed changed so now what we're going to do is we are going to move that directory into the location on the file system where it is going to live until the end of time or for the life of the server and i'm going to move it into slash var slash www so if i list the storage of var www you can see that directory now lives there so now let's disable that default site the one that we saw when we first went to the ip address of the server in the browser after installing apache let's actually get rid of it and to do that we can run sudo a2 dis site zero zero zero we can actually press tab right here it auto completes it because it knows what file i'm referring to already when i start typing the first three characters so that is the config file for that default page i'm disabling that essentially now it's telling me that i need to run systemctl reload apache 2 for that change to take effect let's go ahead and do that and that was pretty easy so now that we have disabled that default config file for apache for the default site we need to create a new one that's going to be the config file for next cloud itself so sudo nano slash etsy apache 2 sites hyphen available and then inside that directory i'm going to call it nc.learnlinux.tv my domain and then i'm going to add dot com at the end of that file name and then i'll press enter this is a brand new file it's an empty file so what i'm going to do is paste the contents right here and you can get a copy of that yourself from the wiki article so there it is that is the configuration file for apache that enables it to serve next cloud when people visit our domain or ip address if you don't have a domain just make sure that you adjust everything in this file to match reality on your end so for example if you did not name your directory for the next cloud installation files as i did here and you probably didn't because unless you have this domain you probably named it something else just make sure you change that and that you change the server name here as well and then here i have the path to the next cloud directory yet again make sure that matches same thing here you can name that accordingly and here's well so let's save the file ctrl o and then enter and then ctrl x to exit out and even though we have created that configuration file it's not actually active until we activate it so sudo a2 and site and in my case nc dot learn linux dot tv dot c-o-n-f and then enter and it's telling me that i need to reload apache for this to take effect i'm not going to do that just yet because i have further changes to make to apache i may as well reload it all in one shot and the next thing that we want to do is configure php and this is actually the one command that differs based on the distribution that you're using so what we're going to do is edit a text file and the main difference is that depending on your distribution the text file might be in a different location so sudo nano and then slash etsy slash php 7 dot on ubuntu 2004 it's going to be 7.4 for this part if you are running raspberry pi os or debian 10 in that case it's going to be 7.3 if in doubt just type 7 dot and then press tab and it's going to auto-complete whatever it's supposed to be and that's literally the only thing in this entire process that is going to be different depending on the distribution that you're using between the three that i've tested this process on then inside there you should have an apache 2 directory the file we are going to edit is php.ini now inside this file there's a number of different things that we are going to tweak now the trick in nano is you can hold ctrl and press w and that brings up the search box you can see that down below and in the wiki article i have a list of all the parameters that we are going to edit here the first one is memory underscore limit i'll press enter we see it right here currently set to 128 megabytes and we're going to bump that all the way up to 512. so ctrl w again let's search for something else this time it's upload underscore max and it's actually upload max file size but you don't have to type the whole thing to search for something i think that's good enough i'll press enter it's set to two megabytes i'm going to bump that all the way up to 200 control w again looking for max execution time currently set to 30 and we are going to change that to 360. the next thing that we are going to search for is post max size so i just type post underscore max it's set to 8 megabytes i'm going to change that to 200 and then the next thing date dot time zone and it is commented out i'm going to remove the semicolon in front and at the end i'm going to type america detroit if you don't know what yours is supposed to be then just visit this url right here and see if you can find that out there's all kinds of different time zones i can't go over them all but this is correct for me next control w again op cash dot enable i will uncomment that that's all i needed to do for that op cache and turned strings buffer i'll just leave it as that there it is and 8 is the correct value but i wanted to uncomment that ctrl w again it's cash.max accelerated files i will uncomment that as well 10 000 is a good number for that another op cash value this time memory consumption which is actually right there in front of my face i'm going to uncomment that as well and actually 128 is correct and i will uncomment that as well next op cache.revalidate i will uncomment that as well and i had to search again because i pressed something wrong not sure why but anyway i'm going to change that to 1 and then i will save the file control o and then enter and then control x to exit out now there's actually some apache mods that we need to have enabled as well so for that we will run sudo a2 and mod and then dir env headers mime rewrite and ssl these are all recommended by either nexcloud or things that i've run into and found that i've needed it's beyond the scope of this video to describe each of these but these are mods for apache that extend its functionality i'll press enter and many of these have been enabled already that's okay it doesn't matter if we run that command we just want to make sure all of those are enabled and now they are and now we need to restart apache to take advantage of all those mods so sudo systemctl restart apache2 and then we can check the status and as you can see it's running if there were any errors if you've typed something improperly then apache may have failed to restart but it's green it's active and running so we're good so now let's actually configure nextcloud it's partially working at this point or at least it should be partially working let's check now here i still have the default web page that's on my screen right now this no longer technically exists well it does exist it's just not enabled anymore if i refresh this it should change over to next cloud let's see and would you look at that we now have next cloud installed and technically it's running so we need to create a new user for ourselves i'll just use my first name and it's kind of hidden right here but i'm going to tab over and then i'm going to create a password for myself the data folder we can leave alone scroll down database user we use nexcloud for that and then for the password this is the password for the database that you set up earlier in the wiki article as well as on the screen you saw me type it as my password and i recommended that you change that to something secure so hopefully you have done that whatever your password is for the database you add that right there and then for the database name we set that to simply next cloud just like that and i will leave this checked right here install recommended apps and then i will click finish setup this part can take a while so we'll just let it run and now we have a successful installation of nexcloud and go ahead and go through this little welcome here i'll leave it up to you to read this if you want to and we're actually good to go but there's a few things that i recommend that you do that's going to benefit this so let's go back to the terminal so our installation will actually benefit by enabling a memory cache and one of the packages that we have installed has actually already provided us what we need we just have to enable it so for that we will run sudo nano slash var slash www and then your next cloud folder name inside there you should have a config directory and inside that directory you should have a config file config.php and we do and this did not exist until we actually set it up in the browser so we'll go to nearly the end and about right here we'll just press enter and then space a couple of times there and then i'll paste it in right here and we have installed the package that's required to enable apcu so here we're just telling nextcloud to go ahead and load that so control o and then enter to save the file and then ctrl x to exit out it was that simple so next what i recommend that you do is actually correct the permissions of the config file want to actually make the permissions for that file different than the other files and folders that are inside our next cloud folder so we can run sudo chmod 660 slash var slash www next cloud folder config and config.php the same file that we were editing before and then similarly we're going to recall that command we can run ch own rather than chmod for this step we're going to change the ownership to root colon www hyphen data so effectively what we're doing is we are making it so that this config file is owned by the root user and the www hyphen data group so i'll press enter and let's go ahead and make sure that we didn't break anything let's go back to the page you can refresh it and it still works so let's go ahead and click on our name right here and go to settings and then under administration we'll go to overview and this is going to check for any issues that you might have and is telling us that we are connecting over an insecure connection we'll fix that shortly but it's also complaining about missing indexes let's go ahead and fix that back on our terminal let's run the following command sudo php slash var slash www next cloud directory occ space db colon add hyphen missing hyphen indices press enter hopefully i don't have any syntax errors here and well it looks like that worked so now the final step is to create an ssl certificate this is not required you could actually end the video right here and begin using next cloud but if you do have a domain and your server is publicly available then i recommend that you go ahead and finish this so let's install the certbot package which is python3 hyphen certbot hyphen apache i'll press enter and then i'll go ahead and accept the defaults and that will install all the packages that are required to support the cert bot utility which is actually the utility that is used by let's encrypt to facilitate obtaining an ssl certificate which is exactly what we're going to do right now now back on the web page note that it is in fact an insecure connection so this verbiage right here was not lying let's see if we can fix that with the next command so we will run sudo certbot dash dash apache dash d and then the domain name to our next cloud server which is that one in my case i'll press enter for the email address we just put in the email address where we want to actually get the notifications if there's any problems so i will type mine in press enter then i will type a capital a to say that i do agree with that notice and it's asking me if i would be willing to share my email address with the eff they already have that so i'll say no in this case and it's actually working and at this point it's asking us if we would like it to automatically redirect to https and i see no reason not to do that so i will answer with two and then i'll press enter and we're good and i also want to make sure that apache is refreshed this might not be necessary but i will run sudo systemctl restart apache 2. let's check the status make sure that that is working and it is q to exit out of that and back here let's refresh the page and see what happens we have the green padlock here so we know that the certificate has been successful and we do have a warning here about the strict transport security setting you can go ahead and check that out if you'd like but i think at this point you have a next cloud server it's working it's secure it's awesome everything was a complete success so there you go i hope this process has been a success for you and you now have your very own next cloud server i love working with nexcloud it's one of my favorite open source applications and it's awesome to be empowered to run your very own cloud where you call the shots which i think is exactly the benefit of running nexcloud now be sure to subscribe to my channel if you haven't already done so i have some awesome content coming very soon and i will see you in the next [Music] video [Music] so [Music] you
Info
Channel: LearnLinuxTV
Views: 62,659
Rating: 4.9512477 out of 5
Keywords: Linux, Tutorial, Howto, Guide, Distro, Learn Linux, open-source, open source, LearnLinuxTV, LearnLinux.tv, Nextcloud, Ubuntu, Debian, Raspbian, Raspberry Pi OS, Raspberry Pi, Pi, how to, nextcloud setup, nextcloud server, nextcloud install, nextcloud ubuntu, how to install nextcloud, install nextcloud, installation nextcloud, nextcloud installation tutorial, ubuntu server, raspberry pi, nextcloud review, nextcloud server setup, nextcloud server ubuntu, nextcloud server raspberry pi
Id: y4dtcr2NL5M
Channel Id: undefined
Length: 41min 0sec (2460 seconds)
Published: Sun Feb 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.