Mac 或 Mac OS X 中的 localhost 文件夹位于哪里?
我刚刚开始在我的 mac 上开发 PHP 项目(使用 PDT),想知道 localhost 位于哪里? Mac OS X 如何为网站提供服务,我在安装 PDT 期间没有更改任何设置。
I just started developing PHP projects on my mac (using PDT) and was wondering where localhost is located? How does Mac OS X serve websites, I haven't changed any settings during the installation of PDT.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我意识到你需要先开始服务。
启动apache服务
sudo apachectl start
通过点击 localhost 在浏览器中进行测试
您应该在浏览器中收到“可以使用”消息
在
/Library/WebServer/Documents
文件夹中提供您的文件。如有必要,创建目录。重要提示:请注意,在第 3 步中,它是
/Library
而不是~/Library
I realized you need to start service first.
Start apache service
sudo apachectl start
Test in browser by hitting localhost
You should get "It works" message in the browser
Serve your files inside
/Library/WebServer/Documents
folder. Make directories if necessary.Important: Notice in step 3 that it is
/Library
and not~/Library
实际上在较新的 Osx 操作系统中,它存储在
/Library/WebServer/Documents/
中。.en 文件只是一个 html 文件,但需要特殊权限才能更改,所以我只是为我的文件创建了一个文件夹东西,然后通过以下方式访问它
user.local/Folder/file.html
Actually in newer Osx os's, this is stored in
/Library/WebServer/Documents/
The .en file is just an html file, but it needs special permissions to change, so I just made a folder for my stuff and then accessed it by
user.local/Folder/file.html
没有“localhost”文件夹之类的东西; “localhost”一词是本地计算机的别名。默认情况下,apache 服务器的文档根目录是主目录中的“Sites”。
There's no such thing as a "localhost" folder; the word "localhost" is an alias for your local computer. The document root for your apache server, by default, is "Sites" in your home directory.
Macintosh HD/Library/WebServer/Documents
Macintosh HD 是您的 HD 的名称
如果您找不到它: 打开 Finder >点击最顶部的“前往”>电脑>你的高清应该在那里。您可以将高清拖放到左侧的收藏夹中。
Macintosh HD/Library/WebServer/Documents
Macintosh HD is the name of your HD
If you can't find it: Open Finder > click "Go" at the very top > Computer > Your HD should be there. You can drag and drop the HD to favorites on the left.
在 Mac 和 Command+Shift+G 中打开“Finder”,然后输入路径:/usr/local/zend/apache2/htdocs。路径将打开,然后创建/粘贴您的网页/应用程序,然后在浏览器上检查它。
open the 'Finder' in Mac and Command+Shift+G and type in the path:/usr/local/zend/apache2/htdocs. path will open then create/paste your web page/application then check it on the browser.
应用-> XAMPP-> htdocs 这是您应该放置正在构建的网站的文件的地方。
Applications -> XAMPP -> htdocs This is the place where you should put your files for the website you're building.
实际上 mac os x 默认有两个地方提供网站服务:
There are actually two place where mac os x serves websites by default:
对于后代来说,
我从不使用 PHP,所以我完全忘记了 apache 安装在我的 mac 上的位置,因为它在端口 8080 上运行,嘲笑我,安装在非标准路径中。放弃互联网后,我尝试了这个......
因为httpd正在运行,它产生了httpd.config路径,然后云层散开,阳光明亮地显示在我的脸上。 胜利! 因为它里面有通往本地主机的路径。
Mac OS 12 root*
*信用 @cong-lb
For posterity
I never use PHP so I completely forgot where apache was installed on my mac as it was running on port 8080 mocking me, installed in a non-standard path. After giving up on the internet, I tried this...
Because httpd was running it produced the httpd.config path and then the clouds parted and the sun shown brightly on my face. Victory! as within it lies the path to localhost.
Mac OS 12 root*
*credit @cong-lb
默认的 Apache 根文件夹 (localhost/) 是 /Library/WebServer/Documents
另外,请确保在 /etc/apache2/httpd.conf 中加载了 PHP5 模块
The default Apache root folder (localhost/) is /Library/WebServer/Documents
Also, make sure you have the PHP5 module loaded in /etc/apache2/httpd.conf
如果你使用apachectl来启动或停止,那么你可以用这个命令找到它
If you use apachectl to start or stop, then you can find it with this command