Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
nicholasjamesevans

How Do I Run Php On Ubuntu?

Recommended Posts

Hello everyone,

My name is Nicholas, but please feel free to call me Nic. I just bought Larry's "PHP for the Web" book and it has been a great intoduction so far. I've gotten to the part in which Larry talks about getting a phpinfo.php file running. Unfortunately, it covers Windows and OS X, but not linux/Ubuntu.

I am currently running Ubuntu 14.04.2 LTS 64-bit. I am also using Gnome Shell Version 3.12.2 (if that is at all relevant, it wouldn't hurt to know at least)

I have Apache2 installed on my system (2.4.7) and I do not know how to get phpinfo.php running on it.

I'd be happy to add any additional details upon request, and I thank you for your time in regards to this question.

Best,
Nic

 

UPDATE:

Alright, so I've figured it out! The magic of research. I can access "localhost/phpinfo.php" in my web browser. However, phpinfo.php is just a blank white page. This isn't how the page is supposed to appear is it?

 

UPDATE 2:
After further reading, and file editing, I realized that I had not added a ";" to the code for phpinfo.php. What a simple mistake that could cause a lot of frustration. Unfortunately, that did not fix the problem. (1) I know my path is an actual URL starting with http:// (2) I know I have PHP enabled on the server. (3) I am not exactly sure what is meant in the book by "using the proper extension"

 

I have a test.php file that I can open with my localhost. All the code is, is as follows:

<?php

phpinfo();

?>

 

So that file is working properly. (I believe I made it a while back when I first started getting into PHP, but didn't pursue it and soon gave up.) Why would the older test.php file work and not the phpinfo.php?
 

Edited by nicholasjamesevans

Share this post


Link to post
Share on other sites

Thank you Larry! I have the PHP working now, so the server and PHP is good, but the specific file isn't working. Is there possibly anything wrong with my code? It is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en" lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>First PHP Script</title>
    </head>
    <body>
        <?php
        phpinfo();
        ?>
    </body>
</html>

Share this post


Link to post
Share on other sites

There's nothing wrong with your code. Could you elaborate on -how- it's not working? What happens that shouldn't? What should happen but doesn't? Are you seeing error messages? If so, what are they? What URL are you using to run this?

Share this post


Link to post
Share on other sites

There's nothing wrong with your code. Could you elaborate on -how- it's not working? What happens that shouldn't? What should happen but doesn't? Are you seeing error messages? If so, what are they? What URL are you using to run this?

 

Yes, so the code is good. The page in my browser loads as a white blank page. There are no error messages, and I am using http://localhostin Firefox. The other php file is test.php and it has this code:

 

<?php

phpinfo();

?>

 

That file works fine! Which is quite odd. If my code is good on the other file, and my server is working with PHP, why am I seeing a blank white page?

Share this post


Link to post
Share on other sites

Okay, so the strangest thing was going on. That specific file would not work! The code wasn't the problem, the PHP is running fine as well as Apache2.

I deleted phpinfo.php and made a new file with the same exact name, phpinfo.php, and copied the same exact code to it. It worked great. I am happy it works now! But why in the world would that happen?

Share this post


Link to post
Share on other sites

Um...I could really say as to why that would happen without knowing how, exactly, it wasn't working before. But! I'm glad it's working for you now. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...