欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP错误:Forbidden You don't have permission to access / on this server

程序员文章站 2022-05-09 23:44:44
...

用http://localhost/test.php进行的测试,没有发现问题,后来要在内网测试一下就要用IP地址进行那个访问了,如:http://10.10.50.195/test.php,就出现了这个问题。 修改一下php的配置文件httpd.conf。 在原有的位置文件中找到配置节:

  1. Options FollowSymLinks
  2. AllowOverride None
  3. Order deny,allow
  4. Deny from all
  5. Satisfy all
复制代码

修改成:

  1. Options FollowSymLinks
  2. AllowOverride None
  3. Order deny,allow
  4. # Deny from all
  5. Allow from all
  6. #允许所有访问
  7. Satisfy all
复制代码

还有:

  1. #
  2. # Possible values for the Options directive are "None", "All",
  3. # or any combination of:
  4. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  5. #
  6. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  7. # doesn't give it to you.
  8. #
  9. # The Options directive is both complicated and important. Please see
  10. # http://httpd.apache.org/docs/2.2/mod/core.html#options
  11. # for more information.
  12. #
  13. Options Indexes FollowSymLinks
  14. #
  15. # AllowOverride controls what directives may be placed in .htaccess files.
  16. # It can be "All", "None", or any combination of the keywords:
  17. # Options FileInfo AuthConfig Limit
  18. #
  19. AllowOverride all
  20. #
  21. # Controls who can get stuff from this server.
  22. #
  23. # onlineoffline tag - don't remove
  24. Order Deny,Allow
  25. Deny from all
  26. Allow from 127.0.0.1
复制代码

修改成:

  1. #
  2. # Possible values for the Options directive are "None", "All",
  3. # or any combination of:
  4. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  5. #
  6. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  7. # doesn't give it to you.
  8. #
  9. # The Options directive is both complicated and important. Please see
  10. # http://httpd.apache.org/docs/2.2/mod/core.html#options
  11. # for more information.
  12. #
  13. Options Indexes FollowSymLinks
  14. #
  15. # AllowOverride controls what directives may be placed in .htaccess files.
  16. # It can be "All", "None", or any combination of the keywords:
  17. # Options FileInfo AuthConfig Limit
  18. #
  19. AllowOverride all
  20. #
  21. # Controls who can get stuff from this server.
  22. #
  23. # onlineoffline tag - don't remove
  24. Order Deny,Allow
  25. # Deny from all
  26. # Allow from 127.0.0.1
  27. Allow from all
复制代码

然后保存,重启服务,再次访问时发现问题已解决了。