Blog

Setup a Raspberry Pi Web Server with Your Own .COM Using Google Domains

December 28, 2020 by in Agency

hi everyone in this video I’m going to show how to set up a network server with a raspberry secretion I happen to be using an older Raspberry Pi but that’s just because I have a assortment of fullsize SD cards around but it’s exactly the same for the newer Raspberry Pi 3 or the 2 or any other version genuinely in this video I’m going to cover how to set up plainly Linux Apache MySQL PHP we’re going to use SSH to get access to the raspberry pi I’m too going to show how to set up your own domain name like your own comm and how to connect that to your Raspberry Pi and likewise how to use a dynamic DNS service which will let you use your Raspberry Pi on a typical suburban internet attachment where you don’t have a static IP right is a same video before but it didn’t move the domain name part or the dynamic DNS part so that’s why I’m making this video again anyway so gather all your nonsense you’re going to need a Raspberry Pi a SD or micro SD card micro USB cable and a Ethernet cable we’ll start by taking the SD card or micro SD to your normal computer not the Raspberry Pi but your your desktop or laptop and we’ll set up the card ok so back at the computer I’m going to go ahead and connect or plug in my SD card and windows identified it so drive character e ok so if you brought forward by a web browser search for Raspberry Pi downloads and click the first tie-in we want raspbian and we want the minimum portrait all right so it’s almost done downloading in case you’re wondering why I departed with the minimum epitome instead of the full desktop portrait because I’m going to use the Raspberry Pi only as a webserver we really don’t need a graphical user interface and it’ll only is most platforms that need to be updated and could slow things down a little bit so that’s why I’m with negligible you can do it with the full desktop edition if you want that’ll work just fine as well all right the register finished downloading we’ll go ahead and open it and it looks like that would be disk image okay so we want to copy that and save it here so mostly that was a zip file we’re extracting the zip file I’m putting it in my downloads folder you are eligible to made it where you are crave okay so we have raspbian ready to go we need to we need to find a way to settled it on the SD card so if you go to installation leader go down to windows click on the SourceForge link and then click on the download link open the file except create a desktop icon and is moving forward and open it so I’ve noticed that this happens sometimes you’ll get an error and it will say that the requested operation compels hill what that intends is you need to run it as administrator so if we go to the desktop icon liberty clink it flow as administrator and then the error goes away so you need to tell it where your image is so you click on the folder icon and I save mine in my downloads folder but wherever you put it find it and then you need to tell it the drive symbol of your SD card and if you go to file explorer this pc online it happens to be drive note e on yours patently it’ll be different or it could be different so I’ll pick drive symbol E and then click write and confirm and I’m using a very old very slow SD card so this in take a while all right so it finished right into the SD card sound OK click departure and we can go ahead and expel the card and now we’ll go ahead and make the card back to the Raspberry Pi so we got the card that’s all set up go ahead and plug it in plug in your Ethernet cable the other end is already plugged into the back of my router and plug in your microSD cable for influence C the illuminations is everything all right and now we’ll go back to the PC and configure everything through the network so we don’t have to plug in a monitor or a keyboard or a mouse okay so back at our regular computer what we need to do now is we need to figure a pin there there we go okay we need to figure out the IP address of the Raspberry Pi an IP address is like a telephone number for a computer and the highway you can figure that out is by login into your router commonly that’ll be 192 192.168.1.1 okay so I’ve logged into my router yours is probably going to be different because it’ll the boundary will be different for different labels different prototype multitudes that’s the framework multitude I have so you might need to do some experiment to figure out how to make it work with your particular router but on mine if we go to clients and we go to cabled “were having” 192.168.1 the reason why it has that host identify is because I’ve actually use this Raspberry Pi before and it knows by the MAC address the old multitude epithet but it’ll probably say Raspberry Pi so on my particular network with my particular Raspberry Pi it defaulted to 192.168.1.2 to 1 again it it’ll most likely is distinct on your structure and if you don’t have this particular brand of router what you can do is figure out the example number of your router and search for that prototype multitude and then how to set a static IP so on mine if you click the computer icon next to the device you can click a lock icon and that will lock that IP address to this design and you click OK alright and so then the router will reload its a sheet but we’re all does so with that for now now we need a course start fucking talking to that Raspberry Pi and secure eggshell ssh is the way to do that it’s a encrypted commandline interface to a linux computer and the programme I use in Windows to do that it’s called teraterm so te RA te RM and click on the first tie and click on download and we want the most current version which is 4.90 we want the Exe and there it is downloading go ahead and open the file I guess I didn’t open the file um all right go to downloads open the file all right so accept all the defaults should be fine yeah that’s fine pick whatever language you require and we’ll go ahead and opening teraterm okay so when it opens up you’ll see it looks like a daus window behind it and then a little popup window they’ll let you tell it what you want to do so make sure SSH secure shell is selected the default port number of 22 is fine all these are fine the emcee will be that IP address I think it was two to one oh that’s why I didn’t pop up earlier okay what was the IP address two to one yeah so again on yours it’ll probably be different but on mine it’s 1 9 2 1 6 8 1 2 2 1 so you type in whatever you are IP addresses category it in here click OK and it will say well okay it’ll the first time you connect it will bring up this confirmation and sounds continue and then let’s say license or authentication asked username by default is PI P I all lowercase and the password by default is raspberry all lowercase and clink OK and there we go so this is basically a sentiment into the Raspberry Pi this window is your raspberry pi we’re logged in user name is PI the invention honour is raspberry secretion and what we can do now is we want to run the rads PI config program as the administrator so sudo su do is Super User do which makes run it as executive and then R as secretion flair config is the name of the program press Enter all right so the first option expand file system we want to do that that’ll make it so that your partition will take up your entire SD card which is what you requirement so press ENTER and it’ll tell you that it has resized and that it will go into effect after the next reboot so okay conversion user password you probably want to do that so press Enter you’ll be asked for brand-new password press Enter so enter your new UNIX password certainly want to pick something that’s kind of a secret but for this demo I’m just going to select a password of password so don’t do that but password for now press Center type in your password again and it will tell you that it has changed it go down to Boot Alternative and we want be one console basically the other ones would be for a typical like desktop computer but for a server you really don’t need any of that nonsense running in the background so b1 is fine press Enter internationalization alternatives we can change the venue and we’ll scroll down by default it’ll have engb which is the version of English used in Great Britain and I happen to be in the US so I’m going to button it to enus so the ace indicated it has been selected and you can unselect it by pressing room and we’ll go down to enus utf8 and press room and then tab and that’ll bring it about a movie over to okay press Enter and pick enus utf8 press Enter alright go back again to internationalization options pick your time zone and I happen to be in California so I’m going to go to USC it was specific I don’t remember let me go back oh okay going to see America not us go to America and then I’m going to go down to Los Angeles alright everything else is fine we don’t need to change anything else so if you use the privilege arrow you can go to finish and it will say would you like to reboot and yes we do because we want that expanded document organization to go into effect so press ENTER and in a second teraterm will close that’s what happens if it loses a associate so if you ever are doing something and all of a sudden the window closes you lost your network connection anyway so we’re going to go and wait a couple hours for it to finish starting back up and then we’ll open cry a word and connect again is moving forward and open up terror term again and again make sure you use your IP address for the raspberry pi and username is going to be PI the password will now be whatever you designated earlier so again I exploited password which is a bad choice but it’s only for this demo and then click OK and again we have our connection to the Raspberry Pi so we want to do now is download all the updates so that we have a reasonably secure organisation sudo aptget update so again sudo is Super User do which represents run this as an administrator aptget is the tool that will let you interface with the parcel overseer it’s a kind of like the app storage if you demand for Linux kind of and then update tells it to get a list of all the updates so press Enter okay and now and install all of the updates that it might have found so sudo aptget upgrade so update will get the list of informs an ameliorate will actually apply those changes and so it will give us a list of lunch packs that it has noted updates for and that’s in my case that has been 32 updates and it’ll be a download nearly 30 or roughly 24 megabytes and it’s asking us to continue yes or no press enter to yes or to choose yes precisely press enter you so we have all those it’s installed now we can actually go about installing the webserver okay so like before as an administrator we want to install apache2 PHP 5 and then the server and patient for MySQL which is a database and we ensure there is a whole bunch of bundles that will be installed and again we are asked to power to confirm and press ENTER ok so it’s going to ask you to create a password for the MySQL root user MySQL again is the database program which I will not be showing how to use in this particular video but I plan to in future videos and when you connect to MySQL you use a username and password and the seed customer is is the administrator it’s the one that has all the power so utter it a reasonably stick password again for this demo I’m just going to choose a password of password but collect something a little better than that and nature it in again and then the rest of the parcels will continue to install all right so we’ve finished stalling the web server and related boxes let’s substantiate there it is actually ranging so on the not on the Raspberry Pi not here but on your actual regular computer go back to your web browser and type in the IP address of your Raspberry Pi so again mine happen to be 1 9 2 1 6 8 1 2 2 1 but yours will probably be different so don’t precisely indiscriminately kind that in make sure you use the correct one anyway and so you can see here yeah it manipulates this is the default page and then there is some kind of basic steers right here that explain things okay but that’s great now we want to set our web pages here now I mean you could do it all through the authority route but that’ll get really annoying really quick um there’s a program called swish s WI SH and it’ll ok on whoosh SFTP and then it will let you various kinds of see your Raspberry Pi hard drive from within windows and so we’ll download it sounds download and open the file and consent and finish so now if we go to file explorer and go to this PC we envision there is a switch device or drive in this area doubleclick on it and up now click Add SFTP connection we’ll give it a label I’m going to call it web server the multitude would be the IP address of your Raspberry Pi again sort in the one for your Raspberry Pi not just what I typed in user name is going to be PI and the track will be slash home slash PI which is the it’s the dwelling directory of a user in Linux which is kind of like like where substantiates would be click create and so we have a option here and if you double-dealing click on it the first time you connect it will tell you that it has identified itself with a host key that it has not seen before and so you want to tell that you trust that key to store it and go ahead and connect and then we’ll ask for the password which is the password for the user pi so again in this demo my password was password but character in your password and then we see that the folder is empty and if we go up okay check for updates fine let’s see is the folder empty oh it is okay good for a second I thought we had a promulgate so um LS is the Linux equivalent of dir for das which will register all the records in a directory and there’s nothing there what we need to do is we need to create a link in that home directory to where the webpage is restored and they happen to be stored under VAR w w HTML and that index.html is this so we want to replace this eventually so what we want to do is well first of all let’s make it so that the user PI has full read and write access to that directory which means you don’t need to login as an administrator when you want to copy over folders and you can do CH own which is change owner the brand-new owner is the username PI and then the track and oh it is required to do sudo first because you need to you need to be the head to change owners and oh in case you’re not aware I’m use the up arrow key to be submitted by the previous authority you can you can use up and down to to look through your history and now we’ll do a same command but chgrp is deepen group which is another part of Linux duties okay so now the user PI has control over that directory and we’re going to create a link to that directory in the users home directory so Ln s which is make a link and query this for symbolic which is the type of link which is the kind you’re probably thinking of it’s just a regular tie-up and then the resources which is a VAR w w HTML and then the end which will be home PI and yeah we’ll call it HTML all right so now if we go back to windows if we freshen we determine “were having” that folder so and there’s this is the webpage that we find in chrome now let’s go ahead and delete that and if we go back to Chrome if we freshen the sheet you’ll envision everything’s gone because well everything’s gone if you simply want a network server that’ll host you know random files you can drag and remove them over so if we go back to the web browser and we freshen we’ll view we are today have that datum and if you click on it it will laden the register in case you’re wondering this is just a photo of the inside of a calculator a aged form of the ti8 3 plus but anyway that’s irrelevant okay um we could remove that and let’s create a really simple web page so on your on your desktop right click go to new text certificate and call it in stop HTML and I wonder if I believed to be in Windows we need to show the enter extensions because I think that’s index.html and there’s a obscured scatter txt um I accept yeah okay so if you go to your final adventurer go to organize go to change folder and hunting options go to view and then uncheck hide propagations yeah so that’s their own problems that I was hinting after it’s the dot txt we need to remove that so we’re gonna go ahead and rename and clink yes okay so that’s what we need because Apache it’s going to look for a index.html file it is not going to look for an index.html txt anyway so now we have an empty text file and we want to open it with notepad so right click open with choose another app and more apps notepad and check always use the app ok so I’ll make a really simple certainly crude web page okay so really really simple again we’re just going to show a cord of verse in the web browser hello from my Raspberry Pi record save and is moving forward and lag it over alright so now if we go back to our web browser and we freshen great so we have confirmed that we do have a web server it’s running and it’s serving what we want it to serve okay but right now you can only access your server from within your own personal Network it is not accessible on the Internet there’s a duo things we need to do now so that beings on the internet can see your raspberry pi the first thing we should do is tell our router that if it ever receives a request for a webpage that it was necessary transfer it on to the Raspberry Pi and you do that with a I approximate technology announced port forwarding and I’ll go ahead and enter back into my router alright so again this part will vary depending on which prototype of router “youve had” so you’ll need to do some experiment if you have a different model just search for your simulation list and then port forwarding so on my particular router if you go to when W a n which is wide area network and you go to virtual server port 40 so it’ll kind of explain it in these in this paragraph what you do is enable port forward it needs to be yes and then down here we we mount it up so a service word can be whatever you want to call it I’m going to call it web server and port reach will be 18 so well okay it’s not sure I’m knowing it you know there’s HTTP colon slash slash HTTP is by default port 80 so that’s why it’s port 80 and then your neighbourhood IP will be the Raspberry Pi which review for me 192 168 1 2 2 1 again that’ll is distinct for you so pick the correct IP and the local port will too be port 80 and the protocol is TCP and then you click Add all right so really to reiterate we generate it a figure this does not even matter you can call it what it is you demand on the internet if somebody offsets your request to port 80 applying the TCP protocol our router is going to connect that request to the Raspberry Pi on its port 80 and of course that will be with the TCP protocol so sounds apply ok huge so right now if somebody wanted to access my server they would need to know my IP address which has not been able to be this one but it’d be my public IP address and there’s a pair problems of that one is it’d be a lot more convenient if you had a.com or.net or whatever your own domain name and to the majority of residential communications residential internet ties have a dynamic IP and what that wants is your IP address changes over time generally it’s not very often maybe once a week once a few months but but it can change so what we need to do is why did I did Chrome close ok that’s weird whatever if you don’t have a domain name you can buy one and I’ll show you how to do that so domains Don google.com so there’s numerous they call them registrar’s but there’s numerous registrar’s and one of them is dum arenas google.com and they bill about twelve dollars a year and it’s really simple and straightforward you know it’s Google they continue things you are familiar with moderately easily understandable and I’ll log in to my account and prove you how that works so if you don’t have a domain you could you could go here and then you just follow the gradation so you can buy your own calm but I once using them a few cases of them so I’m going to go to manage my lands and I’ll go ahead and login so when you are buy a realm it’ll be listed here and what you can do is for the domain that you want to set it up with which for this demo is going to be CG artwork calm if you go over to DNS and click on that and make sure that you’re using Google’s domain name servers scroll down to synthetic records prefer dynamic DNS and ww4 the yeah WWE GRE comm and then you click Add and then hidden now you need to click this arrow and I’ll go to view credentials so before anyone mentions yes I know I merely evidenced you the username and password for that special DNS configuration thing but before I even revise this video I’m going to reset that if you click need assist adjusting this up I’m going to open that up in a brand-new tab so they explain it all now and it’s good to read through it but basically they register you how to get it on with a DD client and this one that I’ve never heard of before I’ve squandered DD client before but I’ve had issues with it and to be honest it might have been my fault I don’t know but I I’d rather exactly do something more simple and if you go down to here click on using the API the easiest thing you can do is if you access this web page from anywhere on your home network in this case I’ll have the raspberry tart access that Google will know that this is your current IP address and it will modernize its records and so you supersede consumer call and password with the credentials that are right here and you change subdomain yourdomain.com with your arena so in my sample that’ll be WWC gr were calm but again I’ll be different for you so if you try to use that you’ll get an error so continue that in recollection whatever domain name you buy that’s the one you introduced here www whatever your domain is calm and then they schedule now the and by IP equals in but you don’t need to introduced that that’s optional they also tell you down here it’s optional regardles so what we can do is we’ll go back to the raspberry pi I’m going to go ahead and create a script which is really just one wire but it’ll be a shell dialogue that will query that web page so Nano which is a very small basic text editor for Linux and then the folder figure I predict I could call it DNS update script scatter shsh is the extension for a eggshell script press enter all right so we’re now in our text editor and we can create this datum and then save it and a program in Linux for downloading a document is W get and we’re not actually downloading much of anything from them but they will respond with I don’t know ten or twenty courages to let you know if it attained or not so you’re basically doing it download and then let’s copy and adhesive this so that we don’t have to kind it all in so I simulated that if we go back to teraterm there is a neat little shortcut don’t do ctrl V it it isn’t going to work it’ll it’ll do that it’ll go down one boundary if you rightclick with your mouse it will glue and it’s kind of gone off the screen let’s oblige that a bit wider okay there we go so now we need to edit this direction we need to replace user name with the username which will be this one and follow that right click to paste and alteration the password mimic that right click to paste and then change this last part so again for this demo it’s WWC GRE comm but that isn’t going to work for you so make sure you throw in your domain name all right so that will attempt to download that folder what we want to do is we want to save that to a text file and there is an option which is a do a hyphen and then a capital o not zero but a capital o for production and then we can tell it what enter you want to save that supplements I’m going to call it DNS inform develops dot txt and then we’ll create actually will be a two indication dialogue the last line I’m going to append the current date and is necessary to that file and I’ll show you why at the end don’t worry okay so that’s the part script let me review what we’re doing again so we’re scream the W get command which will let you download a datum from the internet in this case the record is really really a web page the web pages address is this long string of text and the first part is the username and then we have a colon password then at subjects google.com lash nick/ inform question mark host may host reputation equals and then your orbit so make sure you put your domain not not this one all right and then capital oh not zero but fund oh four output we specify where we want that file to be saved to so I’m choosing the name DNS update makes speck txt you can call it whatever you miss after it implements stat bid the echo authority down here is going to append a line of textbook to the end of that document and it’ll say last lead and then year is a program in Linux and it will publish out the current date and era these weirdlooking quotes right here those are not single repeats they are I think they’re called a back click it’s the key to the left of the one on your keyboard so if you look at the number one you go to the left or if you look at your tab key go up one it’ll be that weird kind of oblique paraphrase I think it’s an accent in some conversations but regardless that’s what Linux uses to say you know execute this command but then in place of appointment ranged date and then whatever it does framed it here and I’ll show you what this does so we want to save the file and if we look down here it’ll say restraint o that epitomize represents limitation so restrict o for right out so regulate o and it will say file epithet right and that’s what we want so press ENTER and we can exit it’ll tell you down now ensure X for departure so regulate X alright so if we schedule the substance of the index again with LS we have that link to our web page directory and then we have our dialogue now I’m going to go ahead and the write right now so we can see what it does if you do dot lash DNS and oh I roughly forgot because it’s a write it’s basically an executable document and you need to adjust the document permits to move that file executable so chmod is modification I envisage modification Joe plus X is add executable permissions and then the file call press ENTER and now we can do dot slash DNS I’m pressing tab by the way tab will autocomplete a document name alright it is therefore it did that and then we see here that it hopefully saved it to our text file you can use the program cap which is short for concatenate a really interesting specify but um it’ll mostly show you the substance of that file so cat DNS inform develops dot txt press Enter we can see here Google responded with good and then my public IP address and then this is the role that second wrinkle last-place drain and then this was the this is what date print a copy and it etched it in the enter so mostly “were having” our status here whether or not updating our DNS record replaced or neglected and then we have the appointment and age now so that we are able if we look at this file we know you know hey was this run like an hour ago a year ago you know what happened and again this will be visible in Windows so if we go back to swish and to the web server we have it here so if you ever acquired I examine and make sure that you’re updating Google this is how you do it okay but we want to execute this dialogue sporadically because your IP address can change it’d be a good idea to run the script formerly an hour um your IP so we’re not going to change roughly that fast but once an hour it’s probably a good option it isn’t too frequent that you’re going to be annoying Google and it’ll still update your records pretty quickly if your IP changes in linux there is a chrome tab which is a chronological it’s a a program that will run things on a chronological basis so if you type in crontab II which is edit the first time you run this program it will ask you to select a text editor and I want to use Nano because it’s simple and so right here we have two bucket Nano so type in the number two press Enter okay so we have this text file this is going to configure the chrome tab and you go ahead read these paragraphs but I’m going to go ahead and scroll down and get right to it so how it works well here I’ll just go ahead and get it on first okay so first of all you probably wondering what these aim and they kind of hint at it over here your locate is everything all right I ponder my computer is freaking out because I have it running in a VM and my computer is getting kind of hot with the screen recording software and everything anyway okay so the first significance is the minute and what I miss is I want to run this at the start of every hour so basically on the on the zeroth time on me on the first hour and then H is per hour so I’m the zeroth hour of any hour any period of month do M is epoch of month any month any era of week did I put too many IP let’s see minute hour day of month month daytime but yeah okay so I settled I have an extra star okay there we go zero minutes of any hour of any day of the month of any month of any day of the week and then the mastery is our script file home PI DNS update write so basically at you know like it twelve o’clock or one o’clock or two o’clock every every time your hour is it zero for any any any other any hour it’ll operated that dialogue anyway so again we sovereignty zero to write that document press Penetrate and then control X to depart the text editor and you’ll see here that it set the new crontab so right now it’s 154 and in about 6 hours it should feed that program and if we check the contents of this datum it should it’ll probably say something like no modernize or whatever the abbreviation for that is and then it should say here it should say 0 to 0 0 0 0 and if you’re bizarre about what all of the possible responses are they’re down now so we had good oh “its what” I entail earlier so no chg no change we’ll probably see that when it runs in about five minutes because my IP is probably not going to change in the time and then there’s all these possible missteps but yeah general you’re going to see they’re good or no change alright so in theory everything labors now and we’ll give it a shot I don’t know how quickly the because I simply composed this dynamic DNS option I don’t how quickly that’s going to work but let’s go ahead and give it a shot so I’m going to create a brand-new tab and if you remember correctly my domain name for this demo is CG artwork calm and let’s see if it operates your honour not resolved ok so yeah the DNS system has not been modernized quite hitherto it’ll probably take a little while I’m going to go ahead and delay this video and maybe in about half an hour or an hour I’ll try it again and all I’ll show you what happens okay well actually just right after I interrupt this video it it operated so I’ll create a new tab and we’ll go there again and there you can see it employs and this will work from anywhere on the internet um come on wide it’s quite as Chrome save hurtling that’s really annoying okay so that’ll employs numerous we’re on the Internet not just my home network www CGR comm and that is actually in real life serving it from my Raspberry Pi and you so basically that’s all this video is I hope you loved it to summarize we got a Raspberry Pi we prepared an SD card we setup raspbian on it after we set up raspbian we vanished ahead and downloaded all of the updates after that we lay a patchy PHP and MySQL after that we set up swish in Windows so that we can access the raspberry PI’s hard drive from within windows and then I testified you how to well I kind of drawn out how to buy a.com through Google regions and I testify you how to set up one that I’d once bought with dynamic DNS service that Google offer at no additional charge and that’s that’s really all there is to it it’s very simple I know it’s kind of a long video but I was trying to explain things as I became I hope you experienced the video if you have any questions or comments please leave them down below if you like the video delight share with anybody that that might benefit from it if I have go I’ve been various kinds of short-lived on time recently but if I have era I plan to do a knot more videos on how to have an Arduino talk to the Raspberry Pi and also how to set up a VPN server with the Raspberry Pi which can be a really helpful tool if you ever have to travel that’s the end of the video I hope you enjoyed it

Leave a Reply

Your email address will not be published. Required fields are marked *

    Cart