LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-24-2011, 10:23 AM   #1
W_Chevezman
LQ Newbie
 
Registered: Feb 2011
Location: Buenos Aires
Distribution: Ubuntu, Debian, Red Hat, Fedora
Posts: 10

Rep: Reputation: 1
Unhappy 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
 
Old 02-24-2011, 10:32 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 02-24-2011, 10:50 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
 
Old 02-24-2011, 11:23 AM   #4
W_Chevezman
LQ Newbie
 
Registered: Feb 2011
Location: Buenos Aires
Distribution: Ubuntu, Debian, Red Hat, Fedora
Posts: 10

Original Poster
Rep: Reputation: 1
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...
 
Old 02-24-2011, 12:01 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 02-24-2011 at 12:02 PM.
 
Old 02-24-2011, 12:26 PM   #6
W_Chevezman
LQ Newbie
 
Registered: Feb 2011
Location: Buenos Aires
Distribution: Ubuntu, Debian, Red Hat, Fedora
Posts: 10

Original Poster
Rep: Reputation: 1
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
 
Old 02-24-2011, 12:56 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 02-24-2011 at 01:04 PM.
 
Old 02-24-2011, 01:17 PM   #8
goodhombre
Member
 
Registered: Mar 2010
Location: Ungheni, Rep. Moldova
Distribution: Ubuntu
Posts: 89

Rep: Reputation: 22
Quote:
Originally Posted by W_Chevezman View Post
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
 
Old 02-24-2011, 01:36 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
My guess is that /var/www != DocumentRoot

Try a
Code:
grep -r DocumentRoot /etc/apache2/.

Last edited by Tinkster; 02-24-2011 at 01:43 PM. Reason: rem dup
 
Old 02-24-2011, 01:45 PM   #10
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 02-24-2011 at 01:46 PM.
 
Old 02-24-2011, 02:06 PM   #11
W_Chevezman
LQ Newbie
 
Registered: Feb 2011
Location: Buenos Aires
Distribution: Ubuntu, Debian, Red Hat, Fedora
Posts: 10

Original Poster
Rep: Reputation: 1
Thumbs up

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.
 
1 members found this post helpful.
Old 02-24-2011, 02:52 PM   #12
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 02-24-2011, 03:14 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by paulsm4 View Post
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
 
  


Reply

Tags
blank, php5 apache



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Centos 5.2 running Apache 2 and PHP 4 cannot display info.php codenjanod Linux - Server 2 08-19-2008 02:00 AM
PHP & Apache - php files not processing aolong Linux - General 1 12-17-2006 03:09 AM
running apache 2.2 with php 5 sharathg786 Linux - Networking 1 07-19-2006 05:23 AM
Apache 2, PHP 5, SuSE 9.2 - cannot run php files dickohead Linux - Networking 6 06-28-2006 10:25 AM
running apache/php files limp Programming 3 11-07-2004 08:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration