LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   apache (running in Ubuntu 10.10) can't access php files (https://www.linuxquestions.org/questions/linux-software-2/apache-running-in-ubuntu-10-10-cant-access-php-files-864786/)

W_Chevezman 02-24-2011 10:23 AM

apache (running in Ubuntu 10.10) can't access php files
 
Hi everyone,
I'm having a little problem with my Ubuntu 10.10. After install LAMP, apache2 can't access php files; I can see the info from the phpinfo(); but when I create a php file in /var/www and try to access the file (via web browser), the page is blank. If I change the extension to html I can acces without problems.
I checked everythig but I can't understand why any web browser access a blank page.
Nothing appears when I'm cheking the error.log file (apache2)

Anybody have an idea???
Thanks

paulsm4 02-24-2011 10:32 AM

Q: You wrote a PHP file with "phpinfo();", copied it somewhere, displayed it in your browser, and it worked. Correct?

Q: Could you copy/paste this verbatim into "/var/www/test.php", and point your browser to "http://localhost/test.php"?
Code:

<?php
  phpinfo ();
 ?>

What happens?

Thanx in advance .. PSM

tronayne 02-24-2011 10:50 AM

In your httpd.conf file, locate and add index.php like this
Code:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Also, make sure you're including
Code:

# Uncomment the following line to enable PHP (this may vary on your platform):
#
Include /etc/httpd/mod_php.conf

If you added or edited the above, stop and restart httpd (and force a reload of a web page -- in Firefox you shift and click on the reload current page icon). You may also want to put your PHP files in /var/www/htdocs for them to be found.

Hope this helps some.

W_Chevezman 02-24-2011 11:23 AM

Thanks, everybody.
First of all, the phpinfo() works properly and show all the info.
I see that my httpd.conf file is empty... perhaps is not installed well or something happens...
I don't know that to do now...

paulsm4 02-24-2011 12:01 PM

Hi, W_Chevezman -

I understand that "phpinfo()" worked for you. I wanted to verify whether or not "test.php" worked. And, if it did, exactly *which directory* test.php was located in.

/etc/httpd.conf determines which directories the Web server will use, and which directories can execute PHP scripts (among many other things).

But first, before we got into httpd.conf, I wanted to verify that PHP itself was working. A completely SEPARATE problem that could ALSO be causing "white space" is a simple bug in your PHP script. There are LOTS of different things that could be going wrong. So I wanted to take "baby steps" toward a solution.

Q: Could you please create "test.php", and try to execute it through your browser (as "http://localhost/test.php")?
Copy my script verbatim.
Try copying it to /var/www/htdocs/test.php (if you have that directory).
Please let us know exactly what you did, and the exact results (cut/paste error message, if possible)

Q: Exactly what OS and Apache are you running?

Q: Please run the following commands and give us the output:
Code:

uname -a
ls -ld /etc/*apache*
ls -ld /etc/*httpd*
ps -eaf|grep -i apache
ps -eaf|grep -i http


W_Chevezman 02-24-2011 12:26 PM

I'm following your steps:

- I create the file test.php and put your code above. It works, I can see the PHP info page without errors. I don't have /var/www/httpd only /var/www
- OS: Ubuntu Maverick 10.10 / Apache: Apache/2.2.16 (Ubuntu)
- Commands results:
root@pcseginf4:~# uname -a
Linux pcseginf4 2.6.35-25-generic #44-Ubuntu SMP Fri Jan 21 17:40:48 UTC 2011 i686 GNU/Linux

root@pcseginf4:~# ls -ld /etc/*apache*
drwxr-xr-x 7 root root 4096 2011-02-03 09:25 /etc/apache2

root@pcseginf4:~# ls -ld /etc/*httpd*
ls: no se puede acceder a /etc/*httpd*: No existe el fichero o el directorio

root@pcseginf4:~# ps -eaf | grep -i apache
root 2687 1 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2691 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2692 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2693 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2694 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2695 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 2696 2687 0 14:59 ? 00:00:00 /usr/sbin/apache2 -k start
root 2716 2202 0 15:06 pts/2 00:00:00 grep --color=auto -i apache

root@pcseginf4:~# ps -eaf | grep -i http
root 2718 2202 0 15:06 pts/2 00:00:00 grep --color=auto -i http

paulsm4 02-24-2011 12:56 PM

Hi, W_Chevezman -

Cool - thanx! We now know the following:

1. You're running Apache2 on Ubuntu 10.10

2. PHP and your basic Apache configuration are OK: a simple test script (/var/www/test.php) works without problem.

3. Your Apache configuration files are all located here:
Quote:

/etc/apache2/*
4. There's something wrong with your "real" script (hence the "white").

Sooooo .......

Please think about what might be "different" between your "real" script (the one that won't display) and "test.php" (a minimal, "hello world" test case).

If nothing comes to mind, then please cut/paste a snippet (no more than 20-50 lines) of your script. Please use code blocks (to retain script formatting).

Thanx in advance .. PSM

PS:
Please check out this link:

http://php.about.com/od/troubleshoot...e_page_php.htm

PPS:
You can also modify your "php.ini" file to enable full debugging:
Code:

error_reporting  = E_ALL & ~(E_NOTICE | E_USER_NOTICE) ; // display all errors and warnings

goodhombre 02-24-2011 01:17 PM

Quote:

Originally Posted by W_Chevezman (Post 4269908)
root@pcseginf4:~# ls -ld /etc/*apache*
drwxr-xr-x 7 root root 4096 2011-02-03 09:25 /etc/apache2

root@pcseginf4:~# ls -ld /etc/*httpd*
ls: no se puede acceder a /etc/*httpd*: No existe el fichero o el directorio

Apache config file should be in :
Code:

/etc/apache2/apache2.conf
You can find out more details about apache files location using :
Code:

apache2ctl -V

Tinkster 02-24-2011 01:36 PM

My guess is that /var/www != DocumentRoot

Try a
Code:

grep -r DocumentRoot /etc/apache2/.

paulsm4 02-24-2011 01:45 PM

Hi, Tinkster -

We've already ascertained that the config file isn't /etc/httpd.conf, and the DocumentRoot isn't /var/www/htdocs.

The main problem now is "why is W_Chevezman's PHP page 'white'?"

I believe the problem is with a particular PHP script, and I believe there are some good troubleshooting tips here.

IMHO .. PSM

W_Chevezman 02-24-2011 02:06 PM

Thanks paulsm4.
Now I know what's the problem... It was a problem in the php script (strange... when we tested it before it works)... but now we find the error.
You save me.

paulsm4 02-24-2011 02:52 PM

My pleasure :)

And thank you for marking the thread "Solved", and posting back your solution. That's definitely helpful for others who might encounter the same problem.

Tinkster 02-24-2011 03:14 PM

Quote:

Originally Posted by paulsm4 (Post 4269995)
Hi, Tinkster -

We've already ascertained that the config file isn't /etc/httpd.conf, and the DocumentRoot isn't /var/www/htdocs.

Interesting - where did that happen? There was no mention of
DocumentRoot in the thread before my post :} ... never mind.



Cheers,
Tink


All times are GMT -5. The time now is 05:24 AM.