如何对 mac osx 上的本地 php 和 RoR 开发环境进行故障排除? RoR 站点无法正常工作
我在让本地 php 和 Rails 开发环境在 OSX 10.7 上完美配合时遇到了问题。
开发是一种爱好,而我是一个十足的菜鸟。我使用 MAMP 在 PHP 中进行开发。几个月前,我决定尝试一下 RoR,并使用 Passenger 设置一个开发环境。
几周前,当我发现无法访问 MAMP 站点时,我重新安装了 MAMP。
现在我无法访问 RoR 站点。我尝试过重新安装 Passenger。当我输入本地 URL 时,我仍然收到错误“哎呀!Google Chrome 找不到 app.local”。如果我导航到本地主机,我会得到一个“It Works!”页面,因此正在提供某些内容。
我已经用 Pow 进行了实验。如果我导航到本地主机,服务器似乎可以工作,但是当我转到应用程序时,我收到 rake not find 错误。奇怪的是,所有的宝石都在乘客的手下工作。我已经卸载了 Pow。
所以我有三个问题。
1) 如何对我的设置进行故障排除以找出问题所在?我猜这是 Apache 服务器的问题(尽管我可能是错的)。我应该在哪里查找日志文件来帮助解决此问题?
2) 设置本地开发环境以便我可以在 RoR 和 PHP 之间轻松切换的最佳方法是什么? (我知道虚拟化是一种选择,但我宁愿不走这条路,除非有充分的理由)。
3)任何人都可以为初学者推荐有关设置开发环境的良好指南或信息来源吗?我在网上阅读了很多不同的内容,但需要更好地掌握基础知识 - 即了解 gem 文件等的安装位置、bash 文件的正确使用、macports 与 homebrew、passenger 与 pow 等。
感谢您的参与是时候帮助沮丧的初学者了。
安迪
I have run into problems getting my local php and rails development environments to play nicely with each other on OSX 10.7.
Developing is a hobby, and I am a total noob. I use MAMP for developing in PHP. A few months a ago I decided to give RoR a whirl, and set up a dev environment using Passenger.
A couple of weeks ago I reinstalled MAMP when I noticed I could not access the MAMP sites.
Now I can't access the RoR sites. I've tried reinstalling Passenger. I still get the error "Oops! Google Chrome could not find app.local" when I type the local URL. If I navigate to localhost, I get an "It Works!" page, so something is being served.
I have experimented with Pow. The server seems to work if I navigate to localhost, but when I go to the app I get a rake not found error. Strange, as all the gems worked under Passenger. I've since uninstalled Pow.
So I have three questions.
1) How do I troubleshoot my setup to find out what is going wrong? I'm guessing it is an issue with the Apache server (though I could be very wrong). Where should I look for log files to help resolve this?
2) What is the best way to set up a local dev environment so that I can switch easily between RoR and PHP? (I know that virtualization is an option, but would prefer not to go down this route, unless there is a very good reason to).
3) Can anyone recommend a good guide or source of info for beginners on setting up dev environments? I have read a lot of different things online, but need to get a better grasp of the basics - i.e., understanding where gem files etc are being installed, proper use of bash files, macports vs homebrew, passenger vs pow etc.
Thanks for taking the time to help a frustrated beginner.
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我要回答我自己的问题。我已经在本地运行了 Rails 应用程序,但我仍然没有信心完全理解正在发生的事情。
这就是我所做的。
卸载乘客
通过在系统首选项中右键单击卸载乘客 PrefPane。
更新了所有系统 gems
cd'd 到应用程序目录并更新了所有应用程序 gems
使用 xcodebuild重新安装了 Passenger 重新
编译了 OSX 10.7 的 Passenger Prefpane 并安装了。
删除并读取应用程序到乘客预窗格。
我不确定是什么解决了这个问题,但应用程序现在正在运行。我认为这就是发生的事情。不知何故,Passenger 和 Apache 之间的配置已损坏,重新安装 prefpane 会将正确的行添加回 Apache 配置文件中。
问题是我仍然不知道 Passenger 使用的是哪个 Apache 安装 - mac default、macports 或 MAMP。我认为这就是之前让我困惑的地方,因为我检查的配置文件不正确。
作为副产品,我了解到我的一些 gem 不是最新的或缺少依赖项。这也许可以解释我在 Pow 方面遇到的困难。如果是这样,战俘似乎是比乘客更容易的替代品。
所以,事情已经启动并正在运行,但在了解所有这些配置文件如何工作之前,我还有很长的路要走。我仍然不认为我正在使用我更喜欢使用的 Apache 安装!
编辑
PS:MAMP 也仍在用于 PHP 开发,我可以通过在系统首选项中禁用 Web 共享并启动 MAMP 来轻松地在两者之间切换。所以现在所有问题都解决了!
OK, I'm going to answer my own question. I have got the rails apps running locally, but I still don't feel confident that I fully understand what's happening.
This is what I did.
Uninstalled Passenger
Uninstalled Passenger PrefPane by right clicking in system preference.
Updated all system gems
cd'd to app directory and updated all app gems
Reinstalled Passenger
Recompiled Passenger Prefpane for OSX 10.7 using xcodebuild and installed.
Deleted and readded apps to passnger prefpane.
I'm not sure what fixed it, but the apps are now running. This is what I think happened. Somehow the configuration between Passenger and Apache had become corrupt, and reinstalling prefpane added the correct lines back into the Apache config file.
The problem is that I stil don't know which Apache install Passenger is using- mac default, macports, or MAMP. I think this is what confused me before, as the config file I was checking was not the correct one.
As a byproduct, I have learned that several of my gems were not up to date or missing dependencies. This may explain the difficulties I experienced with Pow. If so, the Pow seems to be a much easier alternative to Passenger.
So, things are up and running, but I still have a long way to go before I understand how all these configuration files a working. I still don;t think I'm using the Apache install that I would prefer to use!
EDIT
PS: MAMP is also still working for PHP development, and I can easily switch between the two by disabling web sharing in system preferences, and launching MAMP. So all issues resolved for now!