LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-26-2008, 04:25 AM   #1
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Rep: Reputation: 15
Exclamation Apache 404 index.php not Found but index.php exists at document root


hello all,

i m facing a problem with the apache server and PHP.
The server is running CentOS 5.2 with preconfigured Apache and PHP (5.1.6).
The document root is /home/www

The problem is I can run some files while other files (the ones I create) gives 404 error.

For example there was a file at /home/www/phpinfo.php and it runs well.
However i made a file at /home/www/test.php but when the invoke it from the browser it gives me "Not Found The requested URL /test.php was not found on this server."

I tried with other file without result. Seems like only the files that existed on the system before runs well, if I create new files they cant be found.

I have no idea what could cause this error. I really need some assistance on this matter. Thank you.
 
Old 07-26-2008, 04:27 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I'm guessing selinux. Can you post

ls -lZ /home/www

You could also try accessing those files after temporarily turning selinux off. Type "setenforce 0" as root from a terminal (setenforce 1 to turn it back on)

Last edited by billymayday; 07-26-2008 at 04:28 AM.
 
Old 07-26-2008, 04:29 AM   #3
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Here is the result,

[root@cl-t110-070cl www]# ls -LZ /home/www
drwxr-xr-x cl-t110-070cl cl-t110-070cl xxxxxxxxxxx
drwxr-xr-x root root cgi-bin
drwxr-xr-x cl-t110-070cl cl-t110-070cl cl-t110-070cl
drwxr-xr-x cl-t110-070cl cl-t110-070cl cl-t110-070cl.privatedns.com
drwxr-xr-x root root images
-rwxrwxr-x chapal ftp index.php
-rw------- root root nohup.out
-rwxrwxr-x root root phpinfo.php
drwxr-xr-x root root phpMyAdmin
-rwxr-xr-x root root test.php
drwxrwxr-x root root testsite
 
Old 07-26-2008, 04:32 AM   #4
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday View Post
You could also try accessing those files after temporarily turning selinux off. Type "setenforce 0" as root from a terminal (setenforce 1 to turn it back on)
Ok, i m trying and posting the result.
Thanks for the amazingly fast response.
 
Old 07-26-2008, 04:36 AM   #5
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
[root@cl-t110-070cl /]# /usr/sbin/setenforce 0
/usr/sbin/setenforce: SELinux is disabled

No luck. Still "The requested URL /test.php was not found on this server."
 
Old 07-26-2008, 04:37 AM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That isn't listing and contexts - are you sure you put the "Z" in? Maybe you don't have SELinuz running. Can you post the output of

cat /etc/selinux/config?
 
Old 07-26-2008, 04:39 AM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Is anything coming up int the httpd logs?
 
Old 07-26-2008, 04:41 AM   #8
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Yes, i put Z there, i m copying directly from putty.

Here it is,

cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
 
Old 07-26-2008, 04:42 AM   #9
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
It's probably ownership or permissions. Try

chmod g+w test.php
 
Old 07-26-2008, 04:47 AM   #10
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday View Post
It's probably ownership or permissions. Try

chmod g+w test.php
Just tried, sitll same error.

Quote:
Originally Posted by billymayday
Is anything coming up int the httpd logs?
Sir, I m new to this. Can you tell me where is the log file located ?
 
Old 07-26-2008, 04:53 AM   #11
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Found the log..

the last several lines have same messeges.

[Sat Jul 26 05:48:54 2008] [error] [client 123.49.40.160] script '/home/www/my_ip_address/test.php' not found or unable to stat

Do you want me to post the entire log ?

[EDIT]
oh why is it looking in /home/www/my_ip_address/test.php ?
shouldnt it look at /home/www/test.php ?

Last edited by mark84; 07-26-2008 at 04:55 AM.
 
Old 07-26-2008, 05:00 AM   #12
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
No, but what's the "xxxxxmyipxxxx" bit (did you overtype this or is this exactly what it said)?

As the message says, apache is looking for /home/www/xxxxxmyipxxxx/test.php not /home/www/test.php

Can you post the output of

find /home/www -name phpinfo.php

and note any references in httpd.conf (in /etc/httpd/conf) of DocumentRoot
 
Old 07-26-2008, 05:02 AM   #13
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Now i have put the test.php at /home/www/my_ip_address/test.php and its working.

Shouldnt it work from /home/www/test.php as my DOCUMENT_ROOT is set to /home/www/ ?
Why is it looking inside /home/www/my_ip_address/ ?
How can i reconfigure the doc root to /home/www/ ?

Thanks for the help so far. Really appreciate it.
 
Old 07-26-2008, 05:06 AM   #14
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
post

grep DocumentRoot /etc/httpd/conf/httpd.conf

and maybe

find /etc/httpd/conf.d -type f | xargs grep DocumentRoot
 
Old 07-26-2008, 05:08 AM   #15
mark84
LQ Newbie
 
Registered: Feb 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday View Post
No, but what's the "xxxxxmyipxxxx" bit (did you overtype this or is this exactly what it said)?
I changed it to xxxxxxx it was the actual ip address like 62.178.90.12

Quote:
Originally Posted by billymayday View Post
As the message says, apache is looking for /home/www/xxxxxmyipxxxx/test.php not /home/www/test.php
Yes, the /home/www/xxxxxmyipxxxx/ was a symbolic link to /home/www/cl-t110-070cl.privatedns.com

To give you a better view,

Dir listing of /home/www

[root@cl-t110-070cl www]# ls -l
total 36
lrwxrwxrwx 1 root root 28 Jul 21 13:42 67.205.111.202 -> cl-t110-070cl.privatedns.com
drwxr-xr-x 2 root root 4096 Jul 21 13:42 cgi-bin
lrwxrwxrwx 1 root root 28 Jul 21 13:42 cl-t110-070cl -> cl-t110-070cl.privatedns.com
drwxr-xr-x 2 cl-t110-070cl cl-t110-070cl 4096 Jul 26 05:59 cl-t110-070cl.privatedns.com
drwxr-xr-x 3 root root 4096 Jul 21 13:42 images
-rwxrwxr-x 1 chapal ftp 38 Jul 25 18:07 index.php
-rw------- 1 root root 24 Jul 21 13:42 nohup.out
-rwxrwxr-x 1 root root 43 Jul 25 18:23 phpinfo.php
drwxr-xr-x 11 root root 4096 Jul 21 13:42 phpMyAdmin
-rwxrwxr-x 1 root root 43 Jul 25 18:24 test.php
drwxrwxr-x 2 root root 4096 Jul 26 05:03 testsite


Dir Listing of /home/www/
[root@cl-t110-070cl www]# cd cl-t110-070cl.privatedns.com
[root@cl-t110-070cl cl-t110-070cl.privatedns.com]# ls -l
total 4
lrwxrwxrwx 1 root root 10 Jul 21 13:42 cgi-bin -> ../cgi-bin
lrwxrwxrwx 1 root root 9 Jul 21 13:42 images -> ../images
lrwxrwxrwx 1 root root 14 Jul 21 13:42 phpinfo.php -> ../phpinfo.php
lrwxrwxrwx 1 root root 13 Jul 21 13:42 phpMyAdmin -> ../phpMyAdmin
-rwxr-xr-x 1 root root 43 Jul 26 05:59 test.php
 
  


Reply

Tags
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
How to change the default webpage configuration from index.php to index.htm, etc meema Linux - Server 4 08-22-2008 09:06 PM
apache index.html doesn't show up but index.php do zoffmann Linux - Server 5 01-28-2008 03:53 PM
Where to put index.php (or index.html) on Slackware 11.0 moonguide Slackware 3 05-08-2007 06:35 PM
apache: shows only my index.php and no other file! xpucto Linux - Software 12 02-21-2006 03:37 AM
Apache php index.php problem neurotic Linux - Software 3 11-18-2003 06:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:15 PM.

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