2 | How to Install a Local Server for PHP | 2023 | Learn PHP Full Course for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in order to set up a website using PHP we have to install what is called a local server and there's a lot of different software out there in the internet that you can get in order to install a local server on your computer I do know that some people are a little bit scared when it comes to installing a server on your computer and I just want to point out that there's nothing to be scared of everything is going to be fine and you're not going to install any sort of viruses anything setting up a server is something that is actually quite easy to do and anyone that does websites do it quite frequently so it's not something that new people should be scared of doing it's something that takes a couple of minutes to do and then you have something running on your computer so when it comes to installing a server there's many different servers you can choose from you have lamp Vamp xampp limp there's many different kinds of servers I did also hear about something called Docker from one of my subscribers in the last video so it's just interesting to see that there's so many different ways to do it what we're going to use however is a server called exam and the argument I have for using exam is that it's easy to set up and it's the one I've been using for many years I'm just really comfortable using exam amp so going inside your computer you can see that we have this website here that I just found called apachefriends.org I'll go ahead and leave a link to it so you can actually see it on screen here basically this is just going to be a piece of software that you're going to download that we're going to start and then it's going to run our server on our computer this means that we can actually run a website that is using PHP on our computer without having to upload our website to the Internet so this makes it very easy to just work on our website offline on our computer just like if it were to just make a HTML website as you can see we have a couple of different versions We can install in here we have for Windows Linux and mac and you can also see what version we're going to install in this case here this is going to be release 8.2.0 which is the PHP version that we're going to run on This Server here so once you've figured out what operating system you're sitting on I bet you probably know already you're going to go and click the button for that one so I'm going to click windows then it's going to install the program for you and if it doesn't you're just going to go ahead and click up here where it says click here then we're going to accept the Privacy pop-up and then we're just going to go and download the latest version which is 8.2.0 so we have the latest version of PHP here so I'm going to go and download it now once you have it downloaded you're just going to go ahead and double click it so we can make sure to install it on our computer and it is important that you take note of where exactly you are installing it since we will have to go in and do a couple of changes to it now if you do get a pop-up like this don't worry too much about it since this is only going to be relevant if we were to install this inside our program files inside our main drive so with that I'm just going to click OK and then we're going to choose where we want to install this program so we're going to make sure all these are ticked on and then I'm going to click next then I'm going to select where I want to install this now as you can see I have it inside my C drive but not inside my program file so I can just go and install it directly on the C drive so I'm just going to go and do that click next then I'm going to choose a language in this case it's going to be English and then we can just go ahead and make it set up our program on our computer so it's just going to unpack and install now if you do insist that you want to install this inside your program files then I do have a link in the description where you can go in and actually make sure there's no warnings popping up when you try to run this program inside the program files but like I said if you just installed it directly inside the C drive like I did here we're not going to have any sort of issues now once you have it installed it's going to ask if you want to start the control panel now if you want to wait with later for now let's just go ahead and not do that because I do want to show where exactly this is installed so you can just open it up from inside your computer so with that I'm going to click finish and then you're going to go into a installed xampp which is inside in my case the C drive so I'm going to go into this PC inside my C drive then I'm going to go down to the bottom here and then you can see I have X amp inside the XM folder we're going to have the actual server files which means that we can scroll down to the bottom and actually run this control panel that we were just asked about so we can just go and click the xamppdashcontrol.exe open it up and then you can see we have a little software in here now the important thing for you to know about in here is that we have two services that we need in order to actually get PHP working one is going to be the Apache server which is the one that we need in order to actually run PHP and the second one is the MySQL server which is used in order to get access to our database so what I can do is I can start these two and then you can see we have them running another tip that I have for you is to make sure that you go down and actually dock this at the bottom since this is the program you're going to have to start every single time you need to start working on your website this means that we need to go down actually dot get or pin it to a taskbar so you have easy access to it next time with this running we now need to set up our website inside This Server here which is very easy to do so we're going to go back inside our folder where we have X amp installed and then you're going to go up to the top here and then you're going to go inside the folder called 8T Docs now in here you're going to find a bunch of files and these are just mainly to welcome you into the XM software so if I were to go inside my browser here and inside the URL I'm going to type localhost and then you can see we get this little website here and this is basically what we see with these files inside the HC docs folder this is basically what this is so we don't really need to have this so what I can do is I can go back inside our folder then I'm just going to delete all the files that we have in here now the important thing for you to know about this folder here is that this is going to be the place where you start creating your websites every time you want to create a new website inside This Server here so what we can do is we can go and create a new root folder so I'm going to right click and say I want to create a new folder I can call this one my website just to give it some kind of name of course you're more than welcome to call whatever you want it to be but in my case I'm just going to call it my website and now what you're going to notice is that inside the browser I can go back inside and type localhost and then you can see we get a list of all the different websites that I have inside this folder here this means that if I were to create a second website go in here create a second one my second website then you can see if I were to refresh in here we now have a new website that we can open up using this server here so if I were to click my website you can now see that we have this website open so going inside your preferred editor in my case this is going to be Visual Studio code I'm going to go ahead and create my first file which means that I'm going to save this file inside this folder that I just created a very good advice for you is to go inside and actually dock the HD docs folder on the side over here so I have quick access to it so what I can do is I can go ahead and go inside find xampp take my HD docs folder and dock it over here in the side so in this sort of way I have quick access to it whenever I have to open my folders here so I can click it go in here let's just go and delete that second website since we don't have actually need it I'm going to go inside my root folder and create a index dot PHP now this is the moment where some people are going to get confused if it came directly from my HTML course because when it comes to PHP we want to make sure that instead of creating HTML files we create a PHP file the main difference here is that we actually allow for PHP to be run inside these files here you can still write HTML just like you can before so you don't need to freak out about your website breaking or anything like that or not being able to write HTML inside these files just because it's called dot PHP and the same thing goes if you have an existing website that you want to convert into a PHP website you can just take all the different HTML files that you have and just change the extension from HTML to PHP on those and it's going to work inside your server and it's not going to break anything by the way I should say that because some people do worry that it is going to break something so I have to say it with this file here I'm going to save it and then you can see we have this front page here so if I were to go back inside my website I can refresh my website and then you can see we get a completely blank page and that's because right now we have the index file running inside our server now depending on the editor you're using because in some cases the editor is just going to work straight away but if you are using visual studio code it may ask you something down here at the bottom it says cannot validate since a PHP installation could not be found this is a very typical thing when you have a new version of Visual Studio code so if you have not set up PHP already inside this software you are going to have to set it up manually inside this text editor here so what you can do if you were quick enough is to make sure you opened up the link it gave you if not then we're going to go up into file go down to preferences go inside your settings then you're going to click on extensions and then you're going to go down to PHP and from in here you can actually set it to where you want to have the executable path set up inside a Json file so go to click this you can now see that we have this one line called psp.validate.executable path and this is where we need to set in the link for our PHP installation which is again inside the exam folder so if I were to go back inside the exam folder go back you can see we have a folder in here called PHP so I'm going to click it and then you can see we have a PHP dot exe file down here at the bottom this is the one we need to link to inside this executable path inside Visual Studio code so what I can do is I can copy my path here go back inside paste it inside the double quotes and then we're going to write backslash PHP dot exe now if you copied the path directly like I did here you want to make sure these are not backslashes but instead forward slashes otherwise you're going to get an error message and once you did this you're just going to go and save the file and then you can close it down and now we have it set up so that we can actually find the PHP version that we're using once we start creating a PHP website so just to kind of test this out let's go ahead and start up a regular HTML website now I'm just going to zoom in for you so you can actually see what is going on here and what I'm going to do is I'm going to go inside the body tags and create a pair of PHP tags which we use in order to write PHP inside a website so what I can do is I can write angle bracket question mark PHP question mark angle bracket and then anything that goes in between here is going to be considered as PHP so just to follow a very popular tradition here let's go ahead and go inside and write Echo double quotes hello world close it off with a semicolon save it go inside our website refresh it and then you can see we get hello world so with that we now know that we have a server running so we can actually write PHP code inside our website and have it display inside the browser and with that in the next video we're going to talk a bit about PHP syntax so we can actually write PHP properly inside our website so hope you enjoyed and I'll see you in the next video [Music] thank you [Music]
Info
Channel: Dani Krossing
Views: 127,767
Rating: undefined out of 5
Keywords: Installing a Local Server for PHP, how to install a server for php, How to Install a Local Server for PHP, how to install xampp, how to install xampp for windows 10, How to setup php, how to setup php in visual studio code, how to install a local server for web development, local server for web development, how to install a web server, learn php basics
Id: GRqw0pBwewY
Channel Id: undefined
Length: 10min 43sec (643 seconds)
Published: Wed Mar 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.