02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Taking our new PHP server for a test run

Now that we added PHP to our server it's time for us to test out and validate that everything is working. In the end of this lesson we will have a running php page on our server.

Video Transcript

00:00All right, so now that we got everything rolling, let's go back onto our server. Let's test out and
00:04see if the PHP configurations are up and running. Before I even do that, what I want to do is I
00:09want to restart our HTTP server just to make sure that there's any lagging configurations.
00:14They're all getting set up. So again, it's very easy. I'm going to call the service
00:19HTPD restart, and I'm going to, oh, I typed here incorrectly. So let me service
00:27HTPD restart. So it's going to stop. It's going to start. We're happy with that. I'm going to
00:33make sure I'm inside of my root and my home folder of the demo account by typing CD and
00:38that squiggly line, which I never know how to call it. I think it's called tilde.
00:42So once I do that, it's time for you to go inside of the folder where we had our server,
00:47we configured it a couple of lessons ago. So I'm going to go inside of our, uh, public,
00:52I believe it was. It was actually CD. It was www. It was, um, example, and it was public.
01:01All right. So we're inside of that folder and let me just see what's inside of there. And we can
01:04see that we have our index at HTML. What I want to do is I want to create now a PHP file with a
01:10dot PHP extension to do that. I'm going to just create a new folder, but I'm getting the file,
01:15but make sure I'm going to call the sudo command because don't forget, even though this is inside
01:19of my home folder in the demo account, it actually, this folder is owned by Apache. So if I try to
01:26create a file here, it won't let me because I don't own the folder. So I'm going to call this
01:30sudo V and I'm going to type here a name of a file. So I'm just going to call it I dot PHP
01:36for a function that we're going to call, which is called PHP info, which is going to give us
01:41info about our server. So I'm going to type your enter. And now that I have this new file,
01:46I'm going to type an I for insert, and I'm going to start writing my PHP script.
01:50Now before you could put PHP script anywhere in a page, not everything has to be PHP. Some of it
01:56could be HTML, for example. So what I want to do is I want to bound the area that is of PHP by
02:02putting these signs lesser than question mark the word PHP, I'm going to break a few lines,
02:07and then I'm going to close it with a question mark and greater than so I'm basically starting
02:12with lesser than and I'm ending it with greater than and I'm bounding where my script will be where
02:17my PHP script would be. Now that I have a bound now that I have an area of starting and closing
02:23for my PHP script, all that's left for me to do is actually to create or call something that
02:29is a PHP to test and see that PHP is working. So to do that, I'm going to call the PHP info
02:34function. As we said, we want to get the information on our server on the version of PHP that we're
02:39running. And this is a function. So I'm going to use the open and close round bracket. And in PHP,
02:45I always end the line with a semicolon. That's it. That's all I had to do to create something
02:51in PHP. So we could test out and see that our server is running and we have PHP inside of it.
02:57All that's left for us to do is to click on the escape and to save the file. Now if you
03:01forgot how to save a file and use using the zoo do the way we do that is using the shift colon,
03:07what was the we want to create that colon. And after we set the colon, I'm going to type W for
03:15writing the file and Q to quit once I'm done writing the file, and I'm going to click on
03:20Enter. So it's going to write the file and then we are going to quit. And there we go. We've just
03:25created a new file, which is called Ida PHP. And if we go back onto our server, and as a reminder,
03:32although our default is our index that HTML, we could have approached that file by typing index
03:38dot HTML, and we would get to the same file. So exactly the same way we want to access that
03:44Ida PHP. So I'm going to type your Ida PHP, I'm going to click on Enter. And here we go,
03:49we're getting all the information about our server configuration. Now, by the way,
03:54this is not something that you would want to have visible to anyone. Because if you create
03:58something like this and expose it to the web, what actually is happening, hackers or other people
04:03will know what versions of software you have, which could mean that they might be able to
04:09config to find out a way to hack into your server. Because don't forget as versions of PHP grow,
04:17usually it's because of bugs. And sometimes it might be security bugs. Same goes for updates and
04:22versions of for example, our server. So if we know that we have the version 2.215 right now,
04:28and we're running on the operating centos, and we know that API version, all these stuff could be
04:34very dangerous if a hacker knew about it, because maybe we didn't notice and there's a new version
04:40of Apache that came out. And there was a security breach in the version that we're currently running
04:44on. So that's why you would never really want to have this on a live server where you would
04:50show this PHP information, but it's very useful as a mythology to test and see that everything is
04:55working. But then again, because now we've done with that example, I'm just going to make sure
04:59for a security perspective, I'm going to go right inside there, I'm just going to comment
05:03out that PHP info, I'm going to press on escape there. And I'm going to save it again by using
05:09the colon and the right and Q that W and Q for quit. And if I go back inside of my application,
05:17I click on refresh, even though I know that my PHP is running, we won't get that information. So
05:21users that might drop onto our site or hackers that might find that page wouldn't be able to use it
05:27against our server. So there you go. We have our server up and running. I just want to talk about
05:32one more thing and we will talk about it right away in the next lesson.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!