douzhi7451 2017-05-24 23:54
浏览 484
已采纳

默认情况下,apache2中没有加载index.php

I just installed Ubuntu 17.04 and set up my LAMP server w/ PHP7 and the PHP modules enabled for Apache2.

When I go to http://localhost/ it defaults to the index.html that is present in /var/www/html and not the index.php that is there. When I go to http://localhost/index.php the php file loads just fine and the php script executes.

In looking at other posts ( index.php not loading by default ) I saw that the preferred solution is to edit the /etc/apache2/mods-enabled/dir.conf file to move the index.php before the index.html in the DirectoryIndex entry.

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

So I did this and saved the file as sudo, restarted the apache service as well as tried restarting the computer and it still serves the index.html first. Any idea? Should I use the .htaccess file solution instead? Thanks!

  • 写回答

1条回答 默认 最新

  • douluyezhen4512 2017-05-25 00:01
    关注

    This is likely a caching issue in your browser when you go to http://localhost/ try pressing Ctrl + F5

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗