Raspberry Pi - Install a LAMP Server (Linux, Apache, MariaDB, PHP)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
please remember that the complete information for the class that you are about to view is at Eli the computer guy comm not only do we have our videos there but we have parts lists diagrams pictures and even complete code examples so if you are watching this video and you want more information please go to Eli the computer guy comm welcome back as you know I am Eli the computer guy and in today's class I'm going to be showing you how to build a basic lamp stack for your Raspberry Pi so when we talk about the lamp stack what we're going to be talking about today is linux apache maria DB and PHP basically Linux is the operating system so we're using the right Raspberry Pi OS as the operating system Apache 2 is the web server so when somebody comes to your server using a web browser this is actually the software that presents the website to that client computer we're going to be using Maria DB today as the database engine that is what provides the database services and then PHP is the backend programming language that's what allows you to connect your web server with your database with your file system with a whole bunch of other stuff so when you have a fold lamp stack on your Raspberry Pi this allows you to build rather robust applications for whatever projects that you're going to be creating one of the things that I really do like about the Raspberry Pi over something like the Arduino is that the Raspberry Pi is a full-fledged computer so when you bring in a values on the GPIO pins so if you have sensors connected to the GPIO pins you're reading temperature values light values that type of thing with the Raspberry Pi you can actually directly input those values into the database so if you have a Maria DB database you can actually insert those values directly into the database tables and then you can have code that presents dynamic reports and all that kind of stuff on the Raspberry Pi itself if you're dealing with in the arduino world there'd we know is simply a micro controller so it's able to pull in at the values from the sensors but once it's pulled in the values from the sensors then you've got to figure out what to do with those values are you simply going to save those values to an SD card pull the SD card out and plug it into a computer and do something with it are you going to send those values to a server using an Ethernet shield or a Wi-Fi stack people send those values using something like a post commander to another server and have that server be able to parse the information that's one of the things that you have to deal with with the Arduino world is you have to build a lot of things and configure them in order to make even a basic solution work the cool thing with a Raspberry Pi is you have the GPIO pin so you can pull in temperature values light values distance values all that kind of stuff but you've also got that CPU with the RAM and the storage and a full lamp stack so you can process everything on board with the Raspberry Pi so this one device basically can do everything for you it can bring in the values from the sensors it can store those values into the database on the device itself then you can go and actually look at dynamic reports using HTML and CSS and PHP to see what's going on with your sensors in real time so today we're going to be building a lamp stack for our Raspberry Pi so there's no real warning warnings for today just a couple of things to think about now the first thing is is I'm going to be showing you how to build a lamp stack on the Raspberry Pi os on the Raspberry Pi so most people when they start using the Raspberry Pi they're going to be using the Raspberry Pi OS to start figuring out how to use the GPIO pins to start figuring out how to do Python coding basically when they're getting used to using a Raspberry Pi most people are simply going to be using the Raspberry Pi OS and so having a full lamp stack on your Raspberry Pi OS will make it easier for you to start playing and experimenting with things right as you're using a thawne e to be able to read a values on the GPIO pins if you have a Maria database on your Raspberry Pi iOS then you can start trying to add those values to the tables in that particular database once you have the values in the tables then you can try to use PHP or Python or whatever e12 then pull out values from those tables parse the information then have other things happen so I think it is a valuable to be able to know how to install the lamp stack on a Raspberry Pi OS and when you were starting out it probably makes a lot of sense to use a full-fledged lamp stack on your Raspberry Pi os what I would recommend though us me just me is that if I was going into a production environment if I was going into the real world I would actually install Ubuntu onto my very pious so again remember when you're dealing with the Raspberry Pi that you can install different distributions of Lennox you can even install a version of Windows under your Raspberry Pi so what I would recommend is I would go with something such as Ubuntu so bunty was kind of my standard go-to I would actually install the Ubuntu operating system on the Raspberry Pi and then simply build the lamp stack and do all the configurations as I normally would with an Ubuntu server so that's just kind of one of those things to be thinking about the difference between the educational environment and in the real production environment again I would I would be using the lamp stack on the Raspberry Pi OS for demonstration and class purposes I would not put that into the real world the other thing to realize is that today I'm going to be showing you how to install Maria DB now to be clear and clear it's not that big a deal right so normally when we're talking about the lamp stack it's Linux Apache my sequel mph P so today I'm going to be showing you how to install Maria DB instead of my sequel Maria DB is a fork of my sequel so basically way back in the day my sequel was its own company it then got purchased by a company called Sun Microsystems and then Oracle gobbled up Sun Microsystems up until that point my sequel had been a basically a completely open source project and so a lot of people were concerned when Oracle purchased Sun Microsystems and then obviously my sequel they were really worried that Oracle was going to turn my sequel proprietary and caused a lot of issues so back when that happened they formed people who really cared forked the open source and my sequel database at that time so they would have Maria DB so basically Maria DB is a fork of my sequel now for all intents and purposes for plot the class today and most things that you will be doing Maria DB is a complete drop in alternative to my sequel so we talked about a drop in alternative to my sequel the idea being is you can simply drop it in and as far as your code and as far as how you interact with it nothing really matters right so you can actually still interact with it using my sequel all the commands you know and my sequel will still work the same basically functionally the way that you interact with do be more or less 99.99% of the time should be identical so you will not even notice the difference to be clear though there are differences between Maria DB and my sequel but that's once you get to a higher level at a point that you should not be watching this class if you're watching this class don't worry about the differences between Maria DB and my sequel all right the reason that I'm actually using Maria DB for this particular lamp implementation so for me at this point in time I still generally use my sequel my sequel for the most part is still open source it's kind of a standard again you know me I'm all for standard standard standard standard standards if there's not a reason to change I don't change that's just how I am that's how I am so normally when I build a lamp stack I do use my sequel but for whatever reason the Raspberry Pi operating system repository no longer allows you to easily be able to install my sequel so if you actually try to install my sequel using simply sudo - get install and then my sequel server like you normally would it will actually fail out on the Raspberry Pi OS and say this is no longer available essentially you have to use the Maria database server instead so again I'm easy I'm music you tell me that's no longer there and I should go with this and it's a drop an alternative and then I will use Maria DB instead so that is why we're using Maria DB there's no there's no technical like there's no really really complicated technical reason we're using Maria DB there's no philosophical reason that we're using right Maria DB the reason that we're using Maria DB today is because when you in stride to install my sequel from the normal repository on Raspberry Pi OS it fails out tell easy-to-install maria DB and again maria DB is essentially a drop-in alternative to my sequel so that's why we're doing maria so it's a bit of a long-winded explanation of why we're doing some of the things today but again this is some of the things that are important to understand when you're going now and you're going to be building your servers because there are there are differences between Maria DOB and my sequel for demonstration purposes for small projects again it really doesn't matter but if you go out into a production environment you might run into hiccups if people are expecting to run into a my sequel database and instead they're running into Maria Beebe you might run into some weird issues there so those are just some of the things to be thinking about and why we're doing things the way that we are today so with that let's go over to the Raspberry Pi and I'll show you how to build your lamp stack so here we are at my Raspberry Pi we are dealing with a clean installation of the Raspberry Pi OS and again especially when you are learning when you're doing demonstrations and projects I would highly recommend you start with a clean installation of the Raspberry Pi OS it'll take you all of about seven minutes to get a new installation so especially since we're dealing with things like permissions and services and that type of thing today you guys realize if you're using an old OS basically something you've been doing experiments and playing around with you may run into configuration problems when you actually try to build this lamp stack today so I would say try to try to start with a clean operating system at least when you're learning so we're gonna do is we're gonna go up here to the terminal we're going to open up the terminal and basically we're just gonna start typing in a whole hell of a lot of commands so the first thing that we're going to do is sudo and then apt-get install and then we are going to install apache2 so Apache - this is the web server so we're simply going to click on this again this is up in the repository so as long as you're connected to the Internet it'll work fine and we're gonna say yes here and then it's going to go through and it's going to install everything that's going to be required for a basic Apache - installation so it's setting up all the stuff here and then at the end of it we will then have a web server and we'll actually be able to present websites from this particular raspberry pi there we go and so what we can do here is we can go up we can just simply click on the internet browser and when this comes up we can simply go over to a new tab we can tie 1:27 point zero point zero point one and as long as the Apache to install properly which I don't have to believe it would you will get this page so basically you get the it works page and all this means is that the Apache web server has in fact installed and so yay it is important to understand though that that is only the Apache component that's not the PHP or the Maria DB component so the next thing that I want to do is I actually want to install PHP so now I'm going to type in sudo yeah - get install and we're gonna say a PHP but then on top of PHP we're going to also add some modules so Lib Pat v2 this is where you want to make sure you don't find finger anything especially when you are videotaping this okay so we do that module and then pap - sequel in order to be able to connect with my sequel then we're going into a hit enter that's going to basically ask if you want to yes and now so this is going to be installing the PHP programming language plus the connections that are required for Apache - and for my sequel honestly here to be completely honest you can simply do install PHP so you can do sudo apt - get installed just PHP without those additional modules I've done that in the past I really haven't run into any problems but I guess the the most appropriate way is to install these modules so you know it's a class I'll show you how to do it the most appropriate way um and so here it's going through what's doing all the configurations and setting everything up and so again PHP is a programming language this is what we'll be able to dynamically write webpages for you so if you go to a page it can go and it can take a look at what's in a database or it can take a look at what's in files and then dynamically write the the page for you or again like if information is coming in like in forms or whatever it can also input that information into your database so this is this is what allows your server to be dynamic with with web web clients that type of thing so then pass that one of the things I want to show you is what happens if you try to install my sequel server so again this is a lamp server of Lennox Apache normally my sequel PHP but if you try to do sudo apt - yeah install my sequel server so this is what you would normally do it to install my sequel server if you hit Enter what you'll see is this let's see here package is not available but is referred to by another package this made me in the package is missing or has been obsoleted blah blah blah so install the Morea DB server instead one of the reasons that I'm actually bringing this up is when I was just doing a little pre research in order to do this class what I was surprised about is in the Raspberry Pi documentation if you go to the Raspberry Pi website and they have all these different projects what one of their projects is building a lamp server and they actually still tell you to install my sequel so to do the sudo apt - get my sequel - server so one of the interesting things one of the reasons that I'm highlighting this is that the documentation on the Raspberry Pi website itself is actually no longer accurate but it is important to understand you can just plug in Moorea DB - server - 10 and this again is a drop-in replacement for my city sequel so we're going to do here then is we're gonna type in sudo yeah I think it and in stall and then we're going to say DB - server - 10 oh right is that all correct I think that is all correct and then hit enter it's gonna go that's a yes and then now this will actually install the Morea database server and again there are differences to be clear there there are differences but for small projects for again dumping information and from the GPIO pins reading information that has been put into the database that type of thing by and large Maria DB should be fine for you you shouldn't you shouldn't notice any any differences that will really matter for your type of coat how you're going to be interacting with things okay so now that we're done with that we then need a run a command in order to kind of clean up the installation for Maria DB and we can actually use a my sequel command to do it again remember Maria DB is simply a fork of my sequel so the my sequel commands will still work we're gonna do my sequel underscore secure underscore installation and what this is going to do is it's going to go through and it's actually going to clean up some of the security issues when you initially install the database engine we're going to do this enter a current password for a root I don't have one set root password and I will just say yes new password is one two three four five six enter one two three four five six or and move anonymous user sure yes disallow root log in remotely yes remove test database and access to it yes reload privileged tables now yes and there we go so basically what that does is it goes through and it cleans up the installation process and tries to make it a little bit more secure for you now one of the interesting things with this is again just to make sure that your database is working is we can simply do sudo my sequel and now we can see that we're actually in the the Maria DB so just like you would go into your my sequel database you can actually go into Maria DB again simply using sudo my sequel so again it's important to understand the same commands will work even though it's a different name and then from here we can do the show databases and we can see these are the databases and then I can do like use oh I don't know my sequel database change and I can do show tables right all I'm doing here is showing you that this is this basically that that normal my sequel database engine that you're used to and so past that we can then simply do exit and we have now exited out the marina DB now the final thing that we need to do is we need to take ownership of the HTML directory so basically if we go to the HTML directory right now the PI user so the default user your you login with does not have ownership of the HTML directory so oh let's your CD bar www sir Canyon directory to there and then we do LS - l4 here and we have the HTML directory and you can see that root root is actually the owner of the HTML directory so if you want to do edit files if you want to add files if you want to do that kind of stuff you can run into problems because your you are not root your PI you're not root so first what we're going to do here is we're simply going to change ownership of the HTML folder so that we can do things such as remove the old file that surly old index that HTML file that's there and put in a new one so we're going to do here is we're simply going to do sudo change own and again the default user is PI you know whatever user you your username you have you know use that and then we're simply going to do HTML and from here that then change the ownership of the HTML folder so again we do LS XML and we can now see that pi is the user account that is now owner of the HTML folder since pi is now the owner of the HTML folder what I'm going to do is I'm actually going to delete the index.html file that's in there so if we change your right drain to HTML and then we do LS - al so we have the index.html right so this right here this right here is the web page that shows up when we go to 127 does 0.01 so 120 7.0 does here about 1 this is the loopback address when I go here this is the web page that shows up so I want to move or I want to get rid of that so I'm going to do is another RM index that page yes and so I lost - L so now it is gone so again if we go here and I now do a refresh we will see that there is no and there is no file there anymore so what I wouldn't want to do is I'm actually going to go and just use the graphical user interface just to show you how this works we will actually go to that directory so we'll go to bar then we'll go to WWE and then we'll go to the HTML folder and then what I want to do is I now want to create an index dot PHP index.php file so we're gonna do okay and then from here I can right click and go to text editor and so what I'm going to do is I'm just going to create a very simple PHP script here just to verify that PHP is working is there going to open a PHP then we're going to use the PHP info function and we're going to simply close PHP so what this does is this this asks for the information about the PHP environment from the computer and then it prints it out on the web page so what I can do here is I can then do simply file save so that is now saved I can then close this and then when I go and I do a refresh here I now get the PHP information so again the shows name on the raspberry pi I'm using the Apache two and it gives me that other basic information so most of the time I ignore this information the important thing here is that this shows you that Apache is working it shows you that PHP is working and it also shows you and that it's all kind of working together the final thing that you may want to do is I did not do this yet but you probably should is actually restart the service so the Apache to service whenever you make modifications you modify the the PHP dot ini file you install anything on to your server you probably want to restart your Apache to service and so to do that you can simply do sudo and then we do service patch fee to restart and this basically just restarts the service loads in whatever configurations you've modified this can be a very important especially if you're new in the server world is remember until you restart a service many times configurations are are loaded into the running configuration so one of the problems I see a lot of new people have is they'll modify the PHP dot ini file or they'll modify some file on a server they will not restart the service and so they'll start ripping their hair out because they don't understand because they modified the file but the service isn't doing what it's what they think it's supposed to do and so then they start doing a lot of stupid stuff the reason it's not doing what it's supposed to do is because you have not restarted the service yet so when you get done when you've installed a patch me too when you install PHP when you install Maria DB then simply restart the Apache two service just verify that that has been restarted so all the configurations are now actually running in Apache 2 and away you go so this is the basic lamp installation for on the Raspberry Pi OS again this will make it easy for you for your low Raspberry Pi to be able to host websites and more importantly you'll now be able to interact with it as a full-fledged web server for the projects that you'll be creating so there you go now you know how to build a lamp stack onto your Raspberry Pi operating system on your Raspberry Pi so you can now have the ability again to host that the web server you have the database engine you have the PHP programming language on top of that you have Python already installed on the Raspberry Pi OS so now you can start trying to create some more sophisticated projects again one of the big things that I want you to take away from this class is to remember in the technology world there's always 25 ways to skin a cat hey there's always there's always a huge number of ways to solve the same problem right so basically when you're thinking about what distribution of operating system you'll use what database engine you'll use what programming languages you will use just realize there's a thousand ways to get to a solution what you have to think about is what is the most appropriate way for you to get to a solution so again I'm showing you the raspberry pi OS because that's kind of the default standard so when I'm teaching you the Raspberry Pi is just easier to go with the Raspberry Pi OS but to be clear if I was creating things in a production environment I would be using Ubuntu right so I'd be using the command line cly an Avant to server that would be installed in the Raspberry Pi if I was actually doing this in a production environment again we start taking a look at the basic lamp stack so normal lamp stack is when a Linux Apache mice sequel and PHP so normally again I would install Ubuntu on the Raspberry Pi and then install Linux Apache my sequel my sequel in PHP on to that abun - but since we're using raspberry pi OS because that's kind of the default standard when you go to install my sequel on to Raspberry Pi OS at this point it currently fails out tells you to use Maria DB instead again Maria DB is fine again there's there there are some differences to be clear to be clear there are there are some differences but really for educational purposes again playing around testing doing demonstrations the differences are not large enough for it to really matter for all intents and purposes Maria DB is a drop-in replacement for my sequel so okay fine we're gonna be using Maria DB here and so that's some of the stuff that you have to be thinking about as a technology professional when you go out in the real world is again what operating systems you use what database engines you use what what coding languages you use so many times what you end up using has nothing to do with what is the best or any of that crap most of it has to do again what are the standards for your corporation what are the requirements for your corporation what you already have maintenance contracts for what you already have institutional knowledge in like all of those things right those are what go into deciding what products you will actually use not the whole concept of I'm only going to use the best yeah that's what noobs say that's a noobs noobs always come in they say/i I will only ever use the best products and I won't ever bug I will never bend my ethics on this and then a year later a year later they're just installing a whole bunch of crap cuz they don't care anymore because they real that's not how the real world of technology works so anyways you now know how to build a full lamp stack onto your Raspberry Pi OS as always I enjoy teaching this class looking forward to seeing the next one welcome back as you know I am Eli the computer guy and in today's class I'm going to be showing you how to build a basic a lamp stack for your Raspberry Pi so when we talk about the lamp stack what we're going to be talking about today is linux apache maria DB and PHP basically Linux is the operating system so we're using the right Raspberry Pi OS as the operating system Apache 2 is the web server so when somebody comes to your server using a web browser this is actually the software that presents the website to that client computer we're going to be using Maria DB today as the database engine that is what provides the database services and then PHP is the backend programming language that's what allows you to connect your web server with your database with your file system with a whole bunch of other stuff so when you have a full lamp stack on your Raspberry Pi this allows you to build rather robust applications for whatever projects that you're going to be creating one of the things that I really do like about the Raspberry Pi over something like the Arduino is that the Raspberry Pi is a full-fledged computer so when you bring in a values on the GPIO pins so if you have sensors connected to the GPIO pins you're reading temperature values like values that type of thing with the Raspberry Pi you can actually directly input those values into the database so if you have a Maria DB database you can actually insert those values directly into the database tables and then you can have code that presents dynamic reports and all that kind of stuff on the Raspberry Pi itself if you're dealing with in the Arduino world there'd we know is simply a micro controller so it's able to pull in at the values from the sensors but once it's pulled in the values from the sensors then you've got to figure out what to do with those values are you simply going to save those values to an SD card pull the SD card out and plug it into a computer and do something with it are you going to send those values to a server using an Ethernet shield or a Wi-Fi stack be able to send those values using something like a post command to another server and have that server be able to parse the information that's coming in that's one of things that you have to deal with with the Arduino world is you have to build a lot of things and configure them in order to make even a basic solution work the cool thing with a Raspberry Pi is you had the GPIO pin so you can pull in temperature values light values distance values all that kind of stuff but you've also got that CPU with the RAM and the storage and a full lamp stack so you can process everything on board with the Raspberry Pi so this one device basically can do everything for you it can bring in the values from the sensors it can store those values into the database on the device itself then you can go and actually look at dynamic reports using HTML and CSS and PHP to see what's going on with your sensors in real time so today we're going to be building a lamp stack for our Raspberry Pi so there's no real warning warnings for today just a couple of things to think about now the first thing is is I'm going to be showing you how to build a lamp stack on the Raspberry Pi OS on the Raspberry Pi so most people when they start using the Raspberry Pi they are going to be using the Raspberry Pi OS to start figuring out how to use the GPIO pins to start figuring out how to do Python coding basically when they're getting used to using a Raspberry Pi most people are simply going to be using the Raspberry Pi OS and so having a full lamp stack on your Raspberry Pi OS will make it easier for you to start playing and experimenting with things right as you're using a thawne e to be able to read a values on the GPIO pins if you have a Maria database on your Raspberry Pi iOS then you can start trying to add those values to the tables in that particular database once you have the values in the tables then you can try to use PHP or Python or what everyone to then pull out values from those tables parse the information then have other things happen so I think it is a valuable to be able to know how to install the lamp stack on a Raspberry Pi OS and when you were starting out it probably makes a lot of sense to use a full fledged lamp stack on your Raspberry Pi OS what I would recommend though usmai just made is that if I was going into a production environment if I was going into the real world I would actually install Ubuntu onto my Raspberry Pi so again remember when you with a Raspberry Pi that you can install different distributions of Lennox you can even install a version of Windows onto your Raspberry Pi so what I would recommend is I would go with something such as Ubuntu so bunty was kind of my standard go-to I would actually install the Ubuntu operating system on the Raspberry Pi and then simply build the lamp stack and do all the configurations as I normally would with an Ubuntu server so that's just kind of one of those things to be thinking about the difference between the educational environment and then the real production environment again I would I would be using the lamp stack on the Raspberry Pi OS for demonstration and class purposes I would not put that into the real world the other thing to realize is that today I'm going to be showing you how to install Maria DB now to be clear and clear it's not that big a deal right so normally when we're talking about the lamp stack it's Linux Apache my sequel and PHP so today I'm going to be showing you how to install Maria DB instead of my sequel Maria DB is a fork of my sequel so basically way back in the day my sequel was its own company it then got purchased by a company called Sun Microsystems and then Oracle gobbled up Sun Microsystems up until that point my sequel had been a basically a completely open source project and so a lot of people were concerned when Oracle purchased Sun Microsystems and then obviously my sequel they were really worried that Oracle was going to turn my sequel proprietary and cause a lot of issues so back when that happened they forked people who really cared forked the open source of my sequel database at that time so they would have Maria DB so basically Maria DB is a fork of my sequel now for all intents and purposes or quite the class today and most things that you will be doing Maria DB is a complete drop in alternative to my sequel so when we talk about a drop in alternative to my sequel the idea being is you can simply drop it in and as far as your code and as far as how you interact with it nothing really matters right so you can actually still interact with it using my sequel all the commands you know and my sequel will still work the same basically functionally the way that you interact with Maria de more or less 99.99% of the time should be identical so you will not even notice the difference to be clear though there are differences between Maria DB and my sequel but that's once you get to a higher level at a point that you should not be watching this class if you're watching this class don't worry about the differences between Maria DB and my sequel all right the reason that I'm actually using Maria DB for this particular lamp implementation so for me at this point in time I still generally use my sequel my sequel for the most part is still open source it's kind of a standard again you know me I'm all for standard standard Center standard standards if there's not a reason to change I don't change that's just how I am that's how I am so normally when I build a lamp stack I do use my sequel but for whatever reason the the Raspberry Pi operating system repository no longer allows you to easily be able to install my sequel so if you actually try to install my sequel using simply sudo apt - get install and then my sequel server like you normally would it will actually fail out on the Raspberry Pi OS and say this is no longer available essentially you have to use the Maria database server instead so again I'm easy I'm music you tell me that's no longer there and I should go with this and it's a drop an alternative and then I will use Maria DB instead so that is why we're using Maria DB there's no there's no technical like there's no really really complicated technical reason we're using Maria bdb there's no philosophical reason that we're using right Maria DB the reason that we're using Maria DB today is because when you install my sequel from the normal repository on Raspberry Pi OS it fails out tell easy-to-install maria DB and again maria DB is essentially a drop-in alternative to my sequel so that's why we're doing maria so it's a bit of a long-winded explanation of why we're doing some of the things today but again this is some of the things that are important to understand when you're going out and you're going to be building your servers because there are there are differences between Maria DB and my sequel for demonstration purposes for small projects again it really doesn't matter but if you go out into a product an environment you might run into hiccups if people are expecting to run into a my sequel database and instead they're running into Maria DB you might run into some weird issues there so those are just some of the things to be thinking about and why we're doing things the way that we are today so with that let's go over to the Raspberry Pi and I'll show you how to build your lamp stack so here we are at my Raspberry Pi we are dealing with a clean installation of the Raspberry Pi OS and again especially when you are learning when you're doing demonstrations and projects I would highly recommend you start with a clean installation of the Raspberry Pi OS it'll take you all of about seven minutes to get a new installation so especially since we're dealing with things like permissions and services and that type of thing today you guys realize if you're using an old OS basically something you've been doing experiments and playing around with you may run into configuration problems when you actually try to build this lamp stack today so I would say try to try to start with a clean operating system at least when you're learning so we're gonna do is you're gonna go up here to the terminal we're going to open up the terminal and basically we're just gonna start typing in a whole hell of a lot of commands so the first thing that we're going to do is sudo and then apt-get install and then we are going to install apache2 so catch v2 this is the webserver and so we're simply going to click on this again this is up in the repository so as long as you're connected to the Internet it'll work fine we're gonna say yes here and then it's going to go through and it's going to install everything that's going to be required for a basic Apache to installation so it's setting up all the stuff here and then at the end of it we will then have a web server and we'll actually be able to present websites from this particular raspberry pi there we go and so what we can do here is we can go up we can just simply click on the internet browser and when this comes up we can simply go over to a new tab we can type in one twenty seven point zero point zero point one and as long as the apache to install properly which i don't have to believe it would you will get this page so basically you get the it works page and all this means is that the a web server has in fact installed and so yay it is important to understand though that that is only the Apache component that's not the PHP or the Maria DB component so the next thing that I want to do is I actually want to install PHP so now I'm going to type in sudo apt - get install and we're gonna say a PHP but then on top of PHP we're going to also add some modules so Lib Pepe - this is where you want to make sure you don't find finger anything especially when you are videotaping this okay so we do that module and then PHP - sequel in order to be able to connect with my sequel then we're going in to a hit enter that's going to basically ask if you want to yes and now so this is going to be installing the PHP programming language plus the connections that are required for Apache - and for my sequel honestly here to be completely honest you can't simply do install PHP so you can do sudo apt - get install just PHP without those additional modules I've done that in the past I really haven't run into any problems but I guess the most appropriate way is to install these modules so you know it's a class I'll show you how to do it the most appropriate way um and so here it's going through it's doing all the configurations and setting everything up and so again PHP is a programming language this is what we'll be able to dynamically write webpages for you so if you go to a page it can go and it can take a look at what's in a database or can take a look at what's in files and then dynamically write the the page for you or again like if information is coming in like in forms or whatever it can also input that information into your database so this is this is what allows your server to be dynamic with with web web clients that type of thing so then past that one of the things I want to show you is what happens if you try to install my sequel server so normally again this is a lamp server or Linux Apache normally my sequel PHP but if you try to do sudo apt - yeah install my sequel server so this is what you would normally do and to install the my sequel server if you hit Enter what you'll see is this let's see here package is not available but is referred to by another package this may be in the package is missing or has been obsoleted blah blah blah so install the Maria DB server instead one of the reasons that I'm actually bringing this up is when I was just doing a little pre research in order to do this class what I was surprised about is in the Raspberry Pi documentation if you go to the Raspberry Pi website and they have all these different projects what one of their projects is built in a lamp server and they actually still tell you to install my sequel so to do the sudo apt - get my sequel - server so one of the interesting things one of the reasons that I'm highlighting this is that the documentation on the Raspberry Pi website itself is actually no longer accurate but it is important to understand you can just plug in Moorea DB - server - 10 and this again it's a drop-in replacement for my stick to sequel so we're going to do here then is we're gonna type in sudo yeah I think it and in stall and then we're going to say DB - server - 10 oh right is that all correct I think that is all correct and then hit enter it's gonna go rather than saying yes and then now this will actually install the Maria database server and again there are differences to be clear there there are differences but for small projects for again dumping information and from the GPIO pins reading information that has been put into the database that type of thing by and large Maria DB should be fine for you you shouldn't you shouldn't notice any any differences that will really matter for your type of code how you're going to be interacting with things okay so now that we're done with that we then need a run a command and/or to kind of clean up the installation for Maria DB and we can actually use a my sequel command to do it again remember Maria DB is simply a fork of my sequel so the my sequel commands will still work we're gonna do my sequel underscore secure underscore installation and what this is going to do is it's going to go through and it's actually going to clean up some of the security issues when you initially install it the database engine we're gonna do this enter a current password for a route I don't have one set root password and I will just say yes new password is one two three four five six enter one two three four five six or and move anonymous user sure yes disallow root log in remotely yes remove test database and access to it yes reload privilege tables now yes and there we go so basically what that does is it goes through and it cleans up the installation process and tries to make it a little bit more secure for you now one of the interesting things with this is again just to make sure that your database is working is we can simply do sudo my sequel and now we can see that we're actually in the the Morea DB so just like you would go into your my sequel database you can actually go into Morea DB again simply using sudo my sequel so again it's important to understand the same commands will work even though it's a different name and then from here we can do that show databases and we can see these are the databases then I can do like use oh my sequel database change and I can do show tables right all I'm doing here is showing you that this is this basically that the normal my sequel database engine that you're used to and so past that we can then simply do exit and we have now exited out of the Morea DB now the final thing that we need to do is we need to take ownership of the HTML directory so basically if we go to the HTML directory right now the PI user so the D faul user your you login with does not have ownership of the HTML directory so oh let's see CD VAR www sir Canyon directory - there and they were do LS - L for here and we have the HTML directory and you can see that root root is actually the owner of the HTML directory so if you want to do edit files if you want to add files if you want to do that kind of stuff you can run into problems because your you are not roof your PI you're not rude so the first what we're going to do here is we're simply going to change ownership of the HTML folder so that we can do things such as remove the old file that's there the old index that HTML file that's there and put in a new one so we're going to do here is we're simply going to do sudo change own and again the default user is PI you know whatever user you your username you have you know use that and then we're simply going to do HTML and from here that then change the ownership of the HTML folder so I'm going to do an LS XML and we can now see that pi is the user account that is now owner of the HTML folder since PI is now the owner of the HTML folder what I'm going to do is I'm actually going to delete the index.html file that's in there so if we change your writer into HTML and then we do LS - L so we have the index.html right so this right here this right here is the web page that shows up when we go to 127 . 0.01 so 127 dot 0 dot 0 dot 1 this is the loopback address when I go here this is the web page it shows up so I want to move or I want to get rid of that so what I do is another RM index.html yes and so I lost - L so now it is gone so again if we go here and I now do a refresh we will see that there is no there is no file there anymore so what I would have wanted is I'm actually going to go and just use the graphical user interface just to show you how this works we will actually go to that directory so we'll go to VAR then we'll go to WWE and then we'll go to the HTML folder and then what I want to do is I now want to create an index dot PHP index.php file so we're gonna do okay and then from here I can right click and go to text editor and so what I'm going to do is I'm just going to create a very simple PHP script here just to verify that PHP is working is there going to open a PHP then we're going to use the PHP info function and we're going to simply close PHP so what this does is this this asks for the information about the PHP environment from the computer and then it prints it out on the web page so what I can do here is I can then do simply file save so that is now saved I can then close this and then when I go and I do a refresh here I now get the PHP information so again the show's name on the Raspberry Pi I'm using the Apache too and it gives me that other basic information so most of the time I ignore this information the important thing here is that this shows you that Apache is working it shows you that PHP is working and it also shows you and that it's all kind of working together the final thing that you may want to do is I did not do this yet but you probably should is actually restart the service so the Apache to service whenever you make modifications you modify the the PHP dot ini file you install anything onto your server you probably want to restart your Apache to service and so to do that and you can simply do sudo and then we do service patch fee to restart and this basically just restarts the service loads in whatever configurations you've modified this can be a very important thing especially if you're new in the server world is remember until you restart a service many times configurations are aren't loaded into the running configuration so one of the problems I see a lot of new people is they'll modify the PHP dot ini file or they'll modify some file on a server they will not restart the service and so they'll start ripping their hair out because they don't understand because they modified the file but the service isn't doing what it's what they think it's supposed to do and so then they start doing a lot of stupid stuff the reason it's not doing what it's supposed to do is because you have not restarted the service yet so when you get done when you install apache2 when you install PHP when you install Maria DB then simply restart the apache to service just verify that that has been restarted so all the configurations are now actually running in apache - and away you go so this is the basic lamp installation on the Raspberry Pi OS again this will make it easy for you to for your low Raspberry Pi to be able to host websites and more importantly you'll now be able to interact with it as a full-fledged web server for the projects that you'll be creating so there you go now you know how to build a lamp stack onto your Raspberry Pi operating system on your Raspberry Pi so you can now have the ability again to host that the web server you have the database engine you have the PHP programming language on top of that you have Python already installed on the Raspberry Pi OS so now you can start trying to create some more sophisticated projects again one of the big things that I want you to take away from this class is to remember in the technology world there's always 25 ways to skin a cat hey there's always there's always a huge number of ways to solve the same problem right so basically when you're thinking about what distribution of operating system you'll use what database engine you'll use what programming languages you'll use just realize there's a thousand ways to get to a solution what you have to think about is what is the most appropriate way for you to get to a solution so again I'm showing you the raspberry pi OS because that's kind of the default standard so when I'm teaching you the raspberry pi is just easier to go with the Raspberry Pi OS but to be clear if I was creating things in a production environment I would be using Ubuntu right so I'd be using the command cly on an Ubuntu server that would be installed in the Raspberry Pi if I was actually doing this in a production environment again we state to start taking a look in the basic lamp stack so normal lamp stack is when a Linux Apache mice sequel and PHP so normally again I would install whoo bun 2 on the Raspberry Pi and then install Linux Apache my sequel my sequel in PHP on to that abun 2 but since we're using Raspberry Pi OS because that's kind of the default standard when you go to install my sequel on to Raspberry Pi OS at this point it currently fails out tells you to use Maria DB instead again Maria DB is fine again there's there there are some differences do be clear to be clear there are there are some differences but really for educational purposes again playing around testing doing demonstrations the differences are not large enough for it to really matter for all intents and purposes Maria DB is a drop-in replacement for my sequel so okay fine we're gonna be using Maria DB here and so that's some of the stuff that you have to be thinking about as a technology professional when you go out in the real world is again what operating systems you use what database engines you use what what coding languages you use so many times what you end up using has nothing to do with what is the best or any of that crap most of it has to do again what are the standards for your corporation what are the requirements for your corporation what do you already have maintenance contracts for what you already have institutional knowledge in like all of those things right those are what go into deciding what products you will actually use not the whole concept of I'm only going to use the best yeah that's what noobs say that's what noobs noobs always come in they say/i I will only ever use the best products and I will never bug I will never bend my ethics on this and then a year later a year later they're just installing a whole bunch of crap cuz they don't care anymore because they realized that's not how the real world of technology works so anyways you now know how to build a full lamp stack onto your Raspberry Pi OS as always I enjoy teaching this class look forward to seeing at the next one if you like the content that I create please think about going to Eli the computer guy comm and becoming a member or donating please understand that all the educational videos are in front of the paywall that includes the videos that includes the notes the diagrams and the code example all of that is freely available and in front of the paywall but if you want to watch opinion videos or if you want to be able to comment you do need to become a member membership is $5 a month or $60 a year and gives you access to those opinion videos and the ability to comment if you don't want to become a member you just want to give a one-time donation there is also a donate button where you can do that please understand in order to provide the education that I am it does cost money the servers cost money equipment cost money travel cost money all of these things cost a reasonable amount of money and the fact of the matter is is YouTube's advertising program no longer supports creators the way that it used to so if you want to these classes to continue to stick around and you find them to be valuable please think about either becoming a monthly member or donating a few dollars for this project
Info
Channel: Eli the Computer Guy
Views: 19,470
Rating: undefined out of 5
Keywords: Eli, the, Computer, Guy, Repair, Networking, Tech, IT, Startup, Arduino, iot
Id: 8FyqyO-k16M
Channel Id: undefined
Length: 53min 35sec (3215 seconds)
Published: Wed Jul 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.