因此,我在Linux上设置了一个apache2网络服务器.做了一个.php文件,但是当我尝试访问myhost/index.php时,它给了我404 Not Found错误.当我尝试访问myhost时,即使在目录/var/www/html中找不到index.html,它也会给我提供ubuntu默认页面.我已经编辑了dir.conf,所以index.php在前面. PS:制作一个phpinfo.
So I've set up an apache2 webserver on linux. Made a .php file but when I try to access myhost/index.php it gives me the 404 Not Found Error. When I try to acccess 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.
推荐答案首先,我将放置一个带有某种"hello world!"的简单index.html.在您的服务器上,所以当它出现时,无疑是成功的.
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.
仅在浏览器中尝试服务器的IP地址,这应该在/var/www/html中为您提供index.php或index.html.这有助于缩小路径中断的位置(摆脱主机名问题).
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).
如果它是计算机上的虚拟服务器,则如果已设置端口转发,则可能必须使用端口转发值,例如127.0.0.1:8080.
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.
检查/var/www/html上的文件权限,您可以使用此.sh脚本(可能需要使用root privs将用户名替换为root,具体取决于您的设置):
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 {} \;如果设置了防火墙,则需要再次检查端口80是否打开.
If you put up a firewall, you need to double check port 80 is open.
作为最后的努力,您可以在服务器上运行netstat -ant,您应该看到:
As a last ditch effort, you can run netstat -ant on your server and you should see:
tcp6 0 0 :::80 :::* LISTEN表明Apache确实在监听端口80.
Indicating that Apache is indeed listening on port 80.
希望其中一件事可以帮助您解决问题,祝您好运!
Hopefully one of those things will help you figure it out, good luck!
更多推荐
Apache2找不到/index.php错误404
发布评论