Getting 404 error while accessing php page in apache in simple php application?
I created a simple php file sample.php
under/var/www/project/dummy/test/sample.php
Here httpd.conf
Listen 8080
<VirtualHost *:8080>
ServerName example.com
DocumentRoot "/var/www/projects/dummy/test"
<Directory "/var/www/projects/dummy/test">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
Here sample.php
(just checking if memcache is enabled)
<? php
if(class_exists('Memcache')){
echo "found";
}
?>
when i turn to localhost:8080/sample.php
or localhost:8080/test/sample.php
i get 404 error
. I can't figure out what's going wrong.
It worries me why localhost
, if it doesn't work.
To add to that does www.example.com/sample.php
n't even work.
thanks for the help
PS: I mapped the ip address in the /etc/hosts
following:
127.0.0.1 example.com www.example.com localhost
why localhost
doesn't it work?
source to share
The document root is at httpd.conf /var/www/projects/dummy/test
, however you said the files were located at /var/www/project/dummy/test/sample.php
. Note. "Project" is singular in one and plural in the other. This will trigger 404s.
Apache logs are also a good place to start when debugging 404s. I'm not sure which OS you are running, but on Ubuntu they can be found in /var/log/apache2/error.log
.
source to share