【问题标题】:Xampp - Ubuntu - cant access my project in lampp/htdocsXampp - Ubuntu - 无法在 lampp/htdocs 中访问我的项目
【发布时间】:2013-07-11 14:06:21
【问题描述】:

我已将 xampp 安装到 Ubuntu 12.04。我已将我的项目放在文件夹 /opt/lampp/htdocs/project_is_here

当我在浏览器中输入 localhost/soap/php(soap/php 在我的 htdocs 文件夹中)时,index.php 出现以下错误:

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

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

Error 403

localhost
Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7

任何想法如何解决这个问题?我认为这是放置项目的正确位置,因为我尝试了其他地方,它说位置不存在,这个错误在这里消失了,我明白了。

有什么想法吗?

【问题讨论】:

    标签: php ubuntu xampp


    【解决方案1】:
    1. 在 linux 终端中导航到您的 lampp 目录。

       cd /opt/lampp
      
    2. 在命令行输入:

       sudo chmod 777 -R htdocs
      

    问题应该解决了。

    你刚刚做的是:

    导航到包含受保护目录的目录。您的问题是它是一个受系统访问保护的文件夹。当您命令 chmod 777 -R htdocs 时,您将计算机上每个用户的权限设置为“读/写/执行 - 允许”

    0-7 之间的每个数字设置一个权限级别。这是一个更详细地解释这一点的链接。

    http://www.pageresource.com/cgirec/chmod.htm

    '-R' 使命令递归,并将影响 htdocs 以及 htdocs 的所有子目录以及这些子目录的所有子目录等。

    【解决方案2】:

    我遇到了同样的问题,这是我的解决方案:


    1.在终端中

    cd /opt/lampp/etc/
    
    1. 如果您安装了 sublime text,只需键入:

    subl httpd.conf

    3.在sublime中打开配置文件时需要检查这三个块是否如下:

    <Directory />
        AllowOverride All
        Require all granted
    </Directory>
    

    =================================

    <Directory "/opt/lampp/htdocs">
     Options Indexes FollowSymLinks ExecCGI Includes
     AllowOverride All
     Require all granted
    </Directory>
    

    =================================

    User your username
    Group your group name
    

    例如:

    我的用户名是 mhmd,我的组名是 mhmd

    User mhmd
    Group mhmd
    

    希望对你有所帮助..

    【讨论】:

      【解决方案3】:

      很有用,

        0 -> No permission
        1 -> Execute
        2 -> Write
        3 -> write and execute(2 +1)
        4 -> Read
        5 -> Read and execute
        6 -> Read and write
        7 -> read,write and execute
        Then What about three decimal 
      
        1st-digit Owner
      
        2nd- digit Group
      
        3rd- digit Others
      
      test@test:~$ sudo chown -R test:test /var/www/html/folder
      
      test@test:~$ sudo chmod -R 666  /var/www/html/folder //-system user 
      
      test@test:~$ sudo chmod -R 777  /var/www/html/folder // -browser with full
      

      这是什么 777 ? --> 7:你,7:我们,7:他们。

      【讨论】:

      • 777 & 666 是文件权限,777 = 没有权限限制。任何人都可以做任何事。通常不是理想的设置。 666 = 所有用户都可以读取和写入文件。
      • 使用:sudo chmod -R +w /var/www/html/folder
      【解决方案4】:

      我已授予所有权限,但仍然收到错误消息。 转到-> /etc/apache2/sites-available/000-default.conf 设置:DocumentRoot 到 /opt/lampp/htdocs

      一切都为我解决了。 将“DocumentRoot”更改为您的项目所在的文件夹。

      【讨论】:

        【解决方案5】:

        一个可能的原因是您使用的是虚拟主机。

        在这种情况下,请在终端中使用此命令

        sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf
        

        然后在文件末尾添加这段代码

        <VirtualHost *:80>
            DocumentRoot "/opt/lampp/htdocs"
            ServerName localhost
            ServerAlias localhost
            ErrorLog "logs/localhost-error_log"
            CustomLog "logs/localhost-access_log" common
        </VirtualHost>
        

        终于重启XAMPP

        sudo /opt/lampp/lampp restart
        

        【讨论】:

        • 谢谢你..@Hoang Trinh 你节省了我的时间
        • 最后。谢谢。它对我有用。我知道这与我使用虚拟主机有关,但没想到谷歌([我的查询]使用虚拟主机)。
        猜你喜欢
        • 2014-09-05
        • 2013-12-27
        • 2013-12-11
        • 2021-07-13
        • 2016-09-04
        • 1970-01-01
        • 1970-01-01
        • 2015-06-26
        • 2019-02-26
        相关资源
        最近更新 更多