php Xampp访问禁止php

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17816732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:31:13  来源:igfitidea点击:

Xampp Access Forbidden php

phpxampp

提问by NirAv JaIn

I'm a windows user. I've been using xampp for quite a while but suddenly none of my .php files are working now! I get this error message:

我是 Windows 用户。我使用 xampp 已经有一段时间了,但突然间我的 .php 文件都没有工作了!我收到此错误消息:



Access forbidden!

禁止访问!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

您无权访问所请求的对象。它要么受读保护,要么无法被服务器读取。

If you think this is a server error, please contact the webmaster.

如果您认为这是服务器错误,请联系网站管理员。

Error 403

错误 403

localhost Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16

本地主机 Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16



I can see the list of my .php files in localhost/Practice (Practice is the folder where I've saved my files) The file even opens whenever I click on it. But when I click on any 'submit' button inside any of my files, it gives this error. Please help! I updated xampp from 1.8.1 to 1.8.2 but still the same problem persists!

我可以在 localhost/Practice 中看到我的 .php 文件列表(Practice 是我保存文件的文件夹)该文件甚至在我点击它时都会打开。但是,当我单击任何文件中的任何“提交”按钮时,都会出现此错误。请帮忙!我将 xampp 从 1.8.1 更新到 1.8.2 但仍然存在同样的问题!

回答by Tho Vo

Try with this code below, add it in your virtual host config. Add this lines to httpd-vhosts.conffile:

尝试使用下面的代码,将其添加到您的虚拟主机配置中。将此行添加到httpd-vhosts.conf文件中:

<Directory "c:/<path-to-projects>/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Require all granted
</Directory>

I fixed the same issue by this way. Hope it helps.

我通过这种方式解决了同样的问题。希望能帮助到你。

Note:

笔记:

after changes please test it in incognitobecause you redirected by cache

更改后请在隐身模式下进行测试,因为您已通过缓存重定向

回答by rahuldm

if used ubuntu operating system then check chmod of /Practice folder change read write permission

如果使用 ubuntu 操作系统,则检查 /Practice 文件夹的 chmod 更改读写权限

Open terminal press shortcut key Ctrl+Alt+TGoto

打开终端按快捷键 Ctrl+Alt+TGoto

$ cd /opt/lampp/htdocs/

$ cd /opt/lampp/htdocs/

and change folder read write and execute permission by using chmodcommand

并使用chmod命令更改文件夹读写和执行权限

e.g folder name is practice and path of folder /opt/lampp/htdocs/practice

例如文件夹名称是文件夹/opt/lampp/htdocs/practice的练习和路径

Type command

键入命令

$ sudo chmod 777 -R Practice

what is chmodand 777? visit this link http://linuxcommand.org/lts0070.php

什么是chmod777?访问此链接 http://linuxcommand.org/lts0070.php

回答by Hammad Khan

The way I resolved this was setup error logs correctly, first

我解决这个问题的方法是正确设置错误日志,首先

<VirtualHost *:80>
    DocumentRoot "D:/websites/test/"
    ServerName test.dev
    ErrorLog "D:/websites/test/logs/error.log"
    CustomLog "D:/websites/test/logs/access.log" common
    <Directory D:/websites/test/>  
        AllowOverride none
        Require all granted  
    </Directory>
</VirtualHost>

After this error are being logged into "D:/websites/test/logs/" make sure to create logs folder yourself. The exact error that was recorded in error log was

将此错误记录到“D:/websites/test/logs/”后,请确保自己创建日志文件夹。错误日志中记录的确切错误是

AH01630: client denied by server configuration:

AH01630:客户端被服务器配置拒绝:

Which pointed me to correct solution using this linkwhich said for the above error

这指出我使用此链接纠正上述错误的解决方案

Require all granted 

is required. My sample sample code above fixes the problem by the way.

是必须的。我上面的示例代码顺便解决了这个问题。

回答by Aasim Yaz

The only solution that worked for me after spending hours researching online

花费数小时在线研究后唯一对我有用的解决方案

sudo chmod -R 0777 /opt/lampp/htdocs/projectname

回答by Raj Kumar

I am using xxamp using ubuntu 16.04 - and its working fine for me

我正在使用 ubuntu 16.04 的 xxamp - 它对我来说工作正常

<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/"
    ServerAdmin localhost
    <Directory "/opt/lampp/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

回答by Florian Braun

Go in to your Xampp folder xampp/apache/conf/extra/httpd-xampp.c-onf

进入你的 Xampp 文件夹 xampp/apache/conf/extra/httpd-xampp.c-onf

Edit the last paragraph:

编辑最后一段:

#close XAMPP sites here 
.
.
.
Deny from all
.
.

to

#close XAMPP sites here 
.
.
.
Allow from all
.
.

or just watch this video: http://www.youtube.com/watch?v=ZUAKLUZa-AU.

或者直接观看这个视频:http: //www.youtube.com/watch?v=ZUAKLUZa-AU

回答by miberg81

For me it was solved instantly by the following

对我来说,它通过以下立即解决

  1. Going to C:\xampp\apache\conf\extra
  2. Editing inside the file httpd-xampp.conf
  3. Edit the file as follows:
  1. 转到 C:\xampp\apache\conf\extra
  2. 在文件 httpd-xampp.conf 内编辑
  3. 编辑文件如下:

find the following lines by cont+f:

通过 cont+f 找到以下几行:

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
    AllowOverride AuthConfig
    Require local
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>

only change local ----> all granted, so it becomes like this

只更改本地 ----> 全部授予,所以它变成这样

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
    AllowOverride AuthConfig
    Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>

After this the localhost will stop showing the error and will show admin panel. I found this solution in a video here: https://www.youtube.com/watch?v=MvYyEPaNNhE

在此之后,本地主机将停止显示错误并显示管理面板。我在这里的视频中找到了这个解决方案:https: //www.youtube.com/watch?v=MvYyEPaNNhE

回答by Victor Ifeanyi Ejiogu

For XAMPP on Mac

对于 Mac 上的 XAMPP

sudo chmod -R 0777 /Applications/XAMPP/xamppfiles/htdocs/myprojectname

NOTE: remember to change 'myprojectname' to your actual project name. Also, make sure the project is on the root directory of htdocs or change the path accordingly.

注意:记住将“myprojectname”更改为您的实际项目名称。另外,请确保项目位于 htdocs 的根目录或相应地更改路径。

回答by MrMadsen

I had this problem after moving the htdocs folder to outside the xampp folder. If you do this then you need to change the document root in httpd.conf. See https://stackoverflow.com/a/1414/3543329.

将 htdocs 文件夹移到 xampp 文件夹之外后,我遇到了这个问题。如果这样做,则需要更改 httpd.conf 中的文档根目录。请参阅https://stackoverflow.com/a/1414/3543329

回答by Seetpal singh

I had the same problem. So I got remembere. Yesterday I had commented this code in htttp-xampp.conf

我有同样的问题。所以我记住了。昨天我在 htttp-xampp.conf 中评论了这段代码

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
#        AllowOverride AuthConfig
#        Require local
#        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

SO I can access my localhost using other system on same network(LAN/WIFI) as it make localhost require local.

所以我可以使用同一网络(LAN / WIFI)上的其他系统访问我的本地主机,因为它使本地主机需要本地。

So I just make it like

所以我只是让它像

Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
#        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

and now its working on my local machine and also localhost is accessible using other systems on same LAN/WIFI.

现在它在我的本地机器上工作,并且可以使用同一 LAN/WIFI 上的其他系统访问 localhost。