Apache 404 index.php not Found but index.php exists at document root
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.
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)
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
Thanks for the amazingly fast response.
[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." :(
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
Is anything coming up int the httpd logs?
Yes, i put Z there, i m copying directly from putty.
Here it is,
# 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.
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
# SETLOCALDEFS= Check local definition changes
It's probably ownership or permissions. Try
chmod g+w test.php
Found the log..
the last several lines have same messeges.
[Sat Jul 26 05:48:54 2008] [error] [client 188.8.131.52] script '/home/www/my_ip_address/test.php' not found or unable to stat
Do you want me to post the entire log ?
oh why is it looking in /home/www/my_ip_address/test.php ?
shouldnt it look at /home/www/test.php ?
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
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. :)
grep DocumentRoot /etc/httpd/conf/httpd.conf
find /etc/httpd/conf.d -type f | xargs grep DocumentRoot
To give you a better view,
Dir listing of /home/www
[root@cl-t110-070cl www]# ls -l
lrwxrwxrwx 1 root root 28 Jul 21 13:42 184.108.40.206 -> 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
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 03:04 PM.|