So in this tutorial we're going to learn how to install a local server on the computer and this is something neat to have when we do want to write PHP code because like I said in the last tutorial PHP is a server-side language meaning if you don't have a server running it won't actually work inside the browser. Now installing a server on your computer is computer and this is something neat to have when we do want to write PHP code because like I said in the last episode PHP is a server-side language meaning if you don't have a server running it won't actually work inside the browser. Now installing a server on your computer is quite easy to do and it's really quick to do it's free and you don't need to worry about it harming your computer in any kind of way.
So what we're going to do is first of all you need to download a software called xampp. Now there's quite a few programs out there you can use to install the server you like using the one called xampp and you know a lot of other people do like it and it's available for both windows, linux and mac. So you're going to open up our browser you're going to go to google and you're going to search for XMPP and the first link would probably be the one going to app at different org. So once you download it and install it do notice where you install it because you're going to have to remember that for later but once you do have it installed you can actually go to your C Drive or D drive wherever you did actually install it and find a folder called xampp. So once you have XM found you need to go into it and notice we do actually have xampp control Exe. If you click it and run it you can see we get this little window here running.

Now this is what you can use to actually run your server and you do actually have an install right now. Once you do install the program called xampp you will have the server installed on your computer. So in all tax to get the server running you have to activate apache and mysql.
This should be running so you go to your browser again go to the URL and you type localhost backs last PHPmyadmin. This will be your localhost where you can see all the different databases we have installed on our server. So in this case we have a couple of them and this is actually a fairly clean new installation of xampp. So here you don't have a lot of databases right now but you can actually go ahead and click on databases up here in the top left corner and create a database. So we can actually even just write something create and you do actually and the button suit should be the same places just in English of course but as you can see that it actually just install a database or set up a database.

In here now databases you use inside
PHP to store data for example when you create maybe a login system in order to have a login system you also need to add users and when users sign up they need to be saved somewhere. So you can actually you know go in and check if the username and password matches each other and that sort of thing .So you need to have a database where you can save all kinds of information and this is actually what you have running right here now.
In order to just write PHP code you don't need to do anything inside PHPmyadmin .All you need to do to get PHP code running or like working is to open up XMP the control panel here and start these two buttons.
Once you have these two started your PHP code is going to work. So you won't actually have to touch PHPmyadmin before you actually need to use databases which is not right now. So once you have these running what you need to do is you need to go back into installed xampp and inside the xampp folder you're going to look for the folder called htdocs. You're going to open it up and in here you can see you have a couple of folders and this is actually your folders that you created. You're most likely going to have some random gibberish in here like some random files which XM installs as a default when you do X installer for the first time. Now what you need to do is highlight all the files you have in here and delete them. Once you deleted all of them you need to right-click and create a new folder. Now this new folder is going to be the root folder for your website meaning that this is where you're going to save all the files for your website. So let's create a folder here called PHP lessons which is going to be your folder. Now you can actually start saving all kinds of PHP code.
Here is a little example of why you need to install the local server. If you go and open up a new document this is a completely clean document and you did not save it or do anything to this one yet if you start out writing PHP code which by the way is inside PHP tags like this. If you want to echo out something which basically means that you want to write something on the screen. You are going to write echo you gonna write "hi0 there!" or "hello there" you gonna save this one inside the folder you just created. So now you going to go inside myhtdocs folder. Now just a little tip for you guys you did actually save Myhtdocs folder inside here inside MyExplorer tab it's quite often if you do a lot of web development so you guys save it over here in the side as well so if you go ahead and save this file you just created inside my PHP license root folder you say index dot PHP because we do have the PHP extension save it.
You guys will notice when you do actually go into my browser go up into my URL and type localhost backslash and then the name of the folder you just created so in you case it was PHP lessons you'll notice that you get some text writing.
Now if you want to actually turn off my control panel and stop these servers and refresh my browser you'll just wait for to load. You guys will see you have no web page available and this is why you need to have the server running because right now you can't actually get a running if you were to actually take this document and just run it inside you browser by right-click on a right clicking on it and opening with your Google Chrome actually it doesn't use it as a default.
Here you did actually need to go find your Google Chrome you do have it here now and you guys would like to notice when you do open it inside Google Chrome just by right-clicking on the file you get the PHP code right there. So it doesn't actually write out hi, oh they're like just hi oh there you can access the entire code there and that's because you don't have a server running. So you do actually need to go start the servers and open it inside your htdocs folder because that's connected to your server and you guys will see you have the text there. So you need to have a server running every time you do PHP code meaning that if you have a website that has PHP code in it you're going to have to use it inside the localhost. Now you might be thinking well what about when we get it online once you do get your website online I'll show you guys how to get a server at least the database running on your server because you will have the server automatically when you upload to an online hosting company. So absolutely guys how to setup a database at some point inside a hosting company if you want you guys can see you did actually write out hi-oh there and it's working. So that's basically all you need it.
One last thing which is if you don't write localhost or don't write anything behind localhost you guys can see you get to the place there what you can see all the different folders you have inside your htdocs folder. As you guys will see if you go back into your htdocs there are the same folders as you have in here. So if you don't want to write anything behind localhost you can actually just go in there and click PHP lessons and there's opens up again so this is how you install a local server and this is all you need to actually get started on PHP .
No comments:
Post a Comment