php Xampp - Ubuntu - 无法在 lampp/htdocs 中访问我的项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17624936/
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
Xampp - Ubuntu - cant access my project in lampp/htdocs
提问by germainelol
I have installed xampp to Ubuntu 12.04. I have put my project in the folder /opt/lampp/htdocs/project_is_here
我已将 xampp 安装到 Ubuntu 12.04。我已将我的项目放在文件夹 /opt/lampp/htdocs/project_is_here
When I type in the browser localhost/soap/php
(soap/php is in my htdocs folder) which is where index.php
I get the following error:
当我在浏览器中输入时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
Any ideas how to fix this? I think this is the right location to put the project, because I tried other places and it said location didnt exist and this error goes away here and I get this.
任何想法如何解决这一问题?我认为这是放置项目的正确位置,因为我尝试了其他地方,但它说位置不存在,并且此错误在这里消失了,我明白了。
Any ideas?
有任何想法吗?
回答by Ryan Mortensen
In the linux terminal navigate to your lampp directory.
cd /opt/lampp
In the command line type:
sudo chmod 777 -R htdocs
在 linux 终端中导航到您的 lampp 目录。
cd /opt/lampp
在命令行输入:
sudo chmod 777 -R htdocs
The problem should be solved.
问题应该得到解决。
1st Edit:
第一次编辑:
What you just did was:
你刚刚做的是:
You navigated to the directory containing the protected directory. Your problem was that it was a folder that was access protected by your system. When you commanded chmod 777 -R htdocs, what you did was set the permissions for everyone on your computer to read/write/execute - allowed.
您导航到包含受保护目录的目录。您的问题是它是一个受系统访问保护的文件夹。当您命令 chmod 777 -R htdocs 时,您所做的是将计算机上每个人的权限设置为读/写/执行 - 允许。
Now, you know what each digit means. It says who the number is about. Now each number from 0-7 sets a permission level. I will simply provide you a link for that.
现在,您知道每个数字的含义了。它说号码是关于谁的。现在从 0-7 的每个数字设置一个权限级别。我将简单地为您提供一个链接。
http://www.pageresource.com/cgirec/chmod.htm
http://www.pageresource.com/cgirec/chmod.htm
I forgot to add why there is a '-R'. '-R' makes the command recursive and will affect htdocs as well as all subdirectories of htdocs and all subdirectories of those etc.
我忘了补充为什么有'-R'。'-R' 使命令递归,并将影响 htdocs 以及 htdocs 的所有子目录和这些目录的所有子目录等。
回答by Mhmd Salem
i've experinced the same problem and this is my solution :
我遇到了同样的问题,这是我的解决方案:
1.in the terminal
1.在终端
cd /opt/lampp/etc/
cd /opt/lampp/etc/
- if you have sublime text installed simply just type :
- 如果您安装了 sublime text,只需输入:
subl httpd.conf
subl httpd.conf
3.when the configuration file opened in sublime you have to check if these three blocks are as follow :
3.在sublime中打开配置文件时,你必须检查这三个块是否如下:
<Directory /> AllowOverride All Require all granted </Directory>
<Directory /> AllowOverride All Require all granted </Directory>
================================
================================
<Directory "/opt/lampp/htdocs"> Options Indexes FollowSymLinks ExecCGI Includes 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
User your username Group your group name
for example :
例如 :
my username is mhmd also my group name is mhmd
我的用户名是 mhmd 我的组名也是 mhmd
User mhmd Group mhmd
User mhmd Group mhmd
and i hope it will help you ..
我希望它会帮助你..
回答by Hoang Trinh
One possible reason is that you are using Virtual host.
一种可能的原因是您使用的是虚拟主机。
In that case, use this command in your terminal
在这种情况下,请在终端中使用此命令
sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf
Then add this block of code at the end of the file
然后在文件末尾添加这段代码
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error_log"
CustomLog "logs/localhost-access_log" common
</VirtualHost>
Finally restart XAMPP
最后重启XAMPP
sudo /opt/lampp/lampp restart
回答by silvertech048
I had given all the permission , still got the error message. Go to -> /etc/apache2/sites-available/000-default.conf set : DocumentRoot to /opt/lampp/htdocs
我已经给了所有权限,但仍然收到错误消息。转到 -> /etc/apache2/sites-available/000-default.conf 设置:DocumentRoot 到 /opt/lampp/htdocs
All solved for me. Change the "DocumentRoot" to whichever folder your project is.
都为我解决了。将“DocumentRoot”更改为您的项目所在的文件夹。
回答by Ponmathavan Mani
it'll useful,
会有用的
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
What is this 777 ? --> 7: you, 7: us, 7: them.
这是什么777?--> 7:你,7:我们,7:他们。