Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Whenever I try to run PHP, it doesn't output anything.

Here's what I'm typing into SSH (where user is a user I created):

php /home/user/public_html/index.php

Any ideas?

share|improve this question
    
I tried creating /home/user/public_html/test.php with nano and put an echo in it and it worked. Why would my index.php not work (it works on my other server)? Do I have to do something with permissions/groups? –  John Jun 23 '09 at 17:37
    
I've updated my answer, but essentially treat this like a bug in your code, and debug it accordingly –  Matt Simmons Jun 23 '09 at 17:48
    
If it works on one server but doesn't on another it's possibly the PHP configuration or you are missing modules/required files. –  Simurr Jun 23 '09 at 17:57

3 Answers 3

try this:

strace /usr/bin/php

(or wherever PHP is installed for you)

That should print out diagnostics on what's going on.

Also, it should be noted that if you just run php, it doesn't print anything, and it waits. Also, it won't print anything if your script doesn't have any output.

Edit

Check the code in the index.php script and make sure it's doing what you want it to be doing. If php is exiting immediately, treat this like a bug in your code.

share|improve this answer
    
It displays a bunch of stuff, but I have no idea how to read/interpret it. –  John Jun 23 '09 at 17:38
    
It's not waiting... the command finishes almost instantly. However, I'm confused as to why nothing is being outputted: there should be output since it works on my other server. –  John Jun 23 '09 at 17:41

Probably it's bombing out on an error, and it's been told not to tell you what that error is. Try adding this to the beginning of your index.php:

error_reporting(E_ALL);
ini_set('display_errors', true);
share|improve this answer
    
Still nothing. If I add an echo before I include the header.php file, it displays. If I add it after, it doesn't display. I think the problem is that my header uses gzip compression. I'm gonna try to get gzip working. –  John Jun 23 '09 at 18:07
up vote 1 down vote accepted

Turns out MySQL wasn't setup and I forgot about that. My bad. Thanks for the help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.