Apache2找不到/index.php错误404

编程入门 行业动态 更新时间:2024-10-06 13:15:47
本文介绍了Apache2找不到/index.php错误404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我在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

本文发布于:2023-11-02 06:56:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551678.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   错误   index   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!