Apache2无法找到/index.php错误404

So I've set up an apache2 webserver on linux. Made a .php file but when I try to access http://myhost/index.php it gives me the 404 Not Found Error. When I try to acccess http://myhost it gives me the ubuntu default page even though there is no index.html to be found in my directory /var/www/html. I have edited the dir.conf so index.php is up front. PS: making a phpinfo.

To start, I would put a simple index.html with some kind of "hello world!" on your server, so when it does come up, it is a clear success.

Things to check

Try only the IP address of the server in the browser, this should give you either the index.php or index.html in the /var/www/html. This helps narrow down where the path breaks down (gets rid of hostname issues).

If it is a virtual server on your computer, you may have to use the port forwarding values like 127.0.0.1:8080, if port forwarding was set up.

Check the file permissions on /var/www/html, you can use this .sh script (might need to replace root with a username with root privs, depending on your setup):

sudo find /var/www -exec chown root:www-data {} \;
sudo find /var/www -type d -exec chmod -v 750 {} \;
sudo find /var/www -type f -exec chmod -v 640 {} \;

If you put up a firewall, you need to double check port 80 is open.

As a last ditch effort, you can run netstat -ant on your server and you should see:

tcp6       0      0 :::80                   :::*                    LISTEN 

Indicating that Apache is indeed listening on port 80.

Hopefully one of those things will help you figure it out, good luck!