LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache 404 index.php not Found but index.php exists at document root (http://www.linuxquestions.org/questions/linux-server-73/apache-404-index-php-not-found-but-index-php-exists-at-document-root-658349/)

mark84 07-26-2008 05:25 AM

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.

billymayday 07-26-2008 05:27 AM

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)

mark84 07-26-2008 05:29 AM

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

mark84 07-26-2008 05:32 AM

Quote:

Originally Posted by billymayday (Post 3226724)
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.

mark84 07-26-2008 05:36 AM

[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." :(

billymayday 07-26-2008 05:37 AM

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?

billymayday 07-26-2008 05:39 AM

Is anything coming up int the httpd logs?

mark84 07-26-2008 05:41 AM

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

billymayday 07-26-2008 05:42 AM

It's probably ownership or permissions. Try

chmod g+w test.php

mark84 07-26-2008 05:47 AM

Quote:

Originally Posted by billymayday (Post 3226738)
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 ?

mark84 07-26-2008 05:53 AM

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 ?

billymayday 07-26-2008 06:00 AM

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

mark84 07-26-2008 06:02 AM

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. :)

billymayday 07-26-2008 06:06 AM

post

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

and maybe

find /etc/httpd/conf.d -type f | xargs grep DocumentRoot

mark84 07-26-2008 06:08 AM

Quote:

Originally Posted by billymayday (Post 3226748)
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 (Post 3226748)
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


All times are GMT -5. The time now is 06:11 PM.