php xampp 找不到我的主文件夹 --Mac os x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12044756/
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 02:42:04  来源:igfitidea点击:

xampp is not finding my home folder --Mac os x

phpnetbeansxampp

提问by learner

I am trying to use XAMPP with NetBeans for PHP. When I move my files to the htdocs folder everything works fine. However when they are in the home folder XAMPP cannot find them. Below is the instruction from XAMPP I followed it but it's not working.

我正在尝试将 XAMPP 与 NetBeans for PHP 一起使用。当我将文件移动到 htdocs 文件夹时,一切正常。但是,当它们位于主文件夹中时,XAMPP 无法找到它们。下面是来自 XAMPP 的说明,我遵循了它,但它不起作用。

     **Where should I put my Websites?**
     You can put your Websites in /Applications/XAMPP/htdocs/ 
     and access them via http://localhost/

     Or you put your Websites in the Sites-Folder in your Home 
     and access them via http://localhost/~leslie/.

回答by mynewaccount

You can change your document root pretty easily by following these instructions:

您可以按照以下说明轻松更改文档根目录:



  1. Locate the file called httpd.conf. Mine is located in this directory: /Applications/XAMPP/etc
  2. Find the line that says:

    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

  3. Change the path to where you want your files to live. Use an absolute path from the root directory (i.e. it should start with a /and if you're using Unix/Linux and a \if you're on Windows).

  4. Still in the httpd.conffile, scroll down a few lines until you see this text:

    # This should be changed to whatever you set DocumentRoot to.
     <Directory "/Applications/XAMPP/xamppfiles/htdocs">
    

    and replace the path with whatever you typed in step 3.

  5. This part is important. In order for these changes to take place, you need to restart Apache (otherwise it won't work). Since you're using XAMPP, just use the GUI to do this (click Stop, and then Start next to the Apache label).

  1. 找到名为httpd.conf. 我的位于此目录中:/Applications/XAMPP/etc
  2. 找到说:

    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

  3. 将路径更改为您希望文件所在的位置。使用根目录的绝对路径(即它应该以 a 开头,/如果您使用的是 Unix/Linux,而 a\如果您使用的是 Windows)。

  4. 仍在httpd.conf文件中,向下滚动几行,直到看到以下文本:

    # This should be changed to whatever you set DocumentRoot to.
     <Directory "/Applications/XAMPP/xamppfiles/htdocs">
    

    并用您在步骤 3 中输入的任何内容替换路径。

  5. 这部分很重要。为了使这些更改发生,您需要重新启动 Apache(否则它将无法工作)。由于您使用的是 XAMPP,因此只需使用 GUI 来执行此操作(单击停止,然后单击 Apache 标签旁边的启动)。

Now, you can put your web content in the new directory (i.e. the home folder in your case)

现在,您可以将您的网络内容放在新目录中(即您的主文件夹)





If, on the other hand, you want to add an additional directory to serve files from, locate the httpd.conffile mentioned in step 1 above, and add this line:

另一方面,如果您想添加一个额外的目录来提供文件,请找到httpd.conf上面步骤 1 中提到的文件,然后添加以下行:

Alias /home ~/
<Directory ~/>
Order allow,deny
Allow from all
</Directory> 

Restart ApacheNow, you can visit localhost/homein your browser and it will serve files from your home directory in addition to the files in your document root (htdocs by default, or whatever you change it to using the steps above).

重新启动 Apache现在,您可以localhost/home在浏览器中访问,除了文档根目录中的文件(默认为 htdocs,或者您使用上述步骤将其更改为任何内容)之外,它还将从您的主目录中提供文件。

回答by EMDEKEY

If you're on mac osx 10.9.xand using XAMPP 1.8.3 (or higher)

如果您使用的是mac osx 10.9.x并使用 XAMPP 1.8.3(或更高版本)

Apple decided to remove the build-in Apache

Apple 决定移除内置的 Apache

  1. open /etc/extras/httpd-userdir.confin your XAMPP Application Folder
  2. Replace UserDir public_html with UserDir Sites
  3. Replace<Directory "/home/*/public">with <Directory "/Users/*/Sites">
  4. open /etc/http.conf
  5. search httd-userdir.confyou should find an entry like the following

    #Include etc/extra/httpd-userdir.conf

    replace it with

    Include etc/extra/httpd-userdir.conf

  6. restart apache

  1. /etc/extras/httpd-userdir.conf在您的 XAMPP 应用程序文件夹中打开
  2. 用 UserDir 站点替换 UserDir public_html
  3. 替换<Directory "/home/*/public"><Directory "/Users/*/Sites">
  4. 打开 /etc/http.conf
  5. 搜索httd-userdir.conf您应该找到如下所示的条目

    #Include etc/extra/httpd-userdir.conf

    将其替换为

    Include etc/extra/httpd-userdir.conf

  6. 重启阿帕奇

Have Fun :)

玩得开心 :)

回答by Andrew G.

Did you put it into either ~/Sites or ~/Sites-Folder?

你把它放在 ~/Sites 或 ~/Sites-Folder 中了吗?

Sounds like you're putting it into ~/

听起来你要把它放进 ~/