laravel Homestead 安装了 PHP7 但我需要 PHP5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34750643/
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
Homestead Installed PHP7 but I need PHP5
提问by Ben Dyer
Homestead randomly stopped working for me, so I tried to remove the whole thing and reinstall, but it's not gone well.
Homestead 随机停止对我来说有效,所以我试图删除整个东西并重新安装,但它并不顺利。
I have it "running" after a day and a half of muddling my way through various issues. However, for reasons that I cannot understand, my Homestead box is now running PHP 7.
经过一天半的混乱解决各种问题后,我让它“运行”。但是,由于我无法理解的原因,我的 Homestead 机器现在运行的是 PHP 7。
The instructionsI was following had optionaloptions for installing PHP 7, but I intentionally skipped that because we are on PHP 5.
我遵循的说明有安装 PHP 7 的可选选项,但我故意跳过了,因为我们使用的是 PHP 5。
For the life of me, I can't figure out how to fix this. Things I have tried:
对于我的生活,我不知道如何解决这个问题。我尝试过的事情:
- I have destroyed and reinstalled the box multiple times.
- I have deleted the VirtualBox box multiple times and redownloaded it.
- I tried installing v0.3.3 of the box based on one suggestion. (I also updated the homestead.rb script accordingly.) At one point, something failed during the install process with
php7.0-fpm: unrecognized service
and the configured sites were returning 502 Bad Gateway errors. - After reinstalling with v.0.4.0, it has started "running" as I described (serves the sites as expected, etc.), but with PHP 7.
- 我已经多次销毁并重新安装了盒子。
- 我已经多次删除 VirtualBox 框并重新下载它。
- 我尝试根据一个建议安装该框的 v0.3.3。(我也相应地更新了 homestead.rb 脚本。)有一次,安装过程中出现了一些失败,
php7.0-fpm: unrecognized service
并且配置的站点返回 502 Bad Gateway 错误。 - 使用 v.0.4.0 重新安装后,它已按照我的描述开始“运行”(按预期提供站点等),但使用 PHP 7。
Searching for solutions has persistently led to a dead-end.
寻找解决方案一直走到了死胡同。
I'm just a dummy front-end developer. :) Laravel, Vagrant, Homestead, all this stuff makes my head hurt. I just want this to work again so I can go back to my actual work. Any advice or alternate avenues of pursuit for researching this problem would be appreciated.
我只是一个虚拟的前端开发人员。:) Laravel、Vagrant、Homestead,所有这些都让我头疼。我只是想让它再次工作,这样我就可以回到我的实际工作中。任何研究此问题的建议或替代途径将不胜感激。
回答by Getsuga
I've been through this issue too and I solved it by installing an old homestead box v0.3.3 and I've used an old release of homestead installer, so I suggest that you remove your current box v0.4.0 and delete your homestead folder then do this:
我也遇到过这个问题,我通过安装一个旧的 homestead box v0.3.3 解决了这个问题,我使用了一个旧版本的 homestead installer,所以我建议你删除你当前的 box v0.4.0 并删除你的 homestead 文件夹然后这样做:
$vagrant box add laravel/homestead --box-version 0.3.3
and then download an older version of Homestead installer from git, I'm using v2.1.8it works fine. Enjoy php 5.6 :)
然后从 git 下载旧版本的 Homestead 安装程序,我使用的是v2.1.8,它工作正常。享受 php 5.6 :)
回答by fuzzy marmot
I had a similar problem where I tried to upgrade Homestead to the most recent Homestead 7.0 box and configure it to run PHP 5.6 instead of PH7, which various sources said was possible via adding a line to the .yaml file specifying the PHP version.
我遇到了类似的问题,我尝试将 Homestead 升级到最新的 Homestead 7.0 机器并将其配置为运行 PHP 5.6 而不是 PH7,各种消息来源表示可以通过在 .yaml 文件中添加一行来指定 PHP 版本。
sites:
- map: myproject.local
to: /home/vagrant/Code/craven/public_html
php: "5.6"
What actually happened when I tried that was that I got a 502 CGI gateway error. Here is a summary of the steps I had to take to fix it:
当我尝试这样做时,实际发生的是我收到 502 CGI 网关错误。以下是我必须采取的修复步骤的摘要:
1) SSH into the Homestead virtual machine.
1) SSH 进入 Homestead 虚拟机。
ssh [email protected] -p 2222
Taking a look at the nginx error log in /var/log/nginx/ reveals that the PHP 5.6 files the server is looking for don't exist.
查看 /var/log/nginx/ 中的 nginx 错误日志显示服务器正在查找的 PHP 5.6 文件不存在。
You can get confirmation of this by having a look at the executables.
您可以通过查看可执行文件来确认这一点。
ls -la /usr/bin/php*
2) To install PHP 5.6, run
2) 要安装 PHP 5.6,请运行
sudo apt-get update
sudo apt-get install php5.6-fpm
You can confirm that the php 5.6 service is running via the command
可以通过命令确认php 5.6服务正在运行
service --status-all
3) Once all this is working, refresh the web page for your site and it should now work. In my case, because I was running a Laravel 4.2 site, I then to install Mcrypt:
3) 一旦所有这些都正常工作,刷新您网站的网页,它现在应该可以工作了。就我而言,因为我运行的是 Laravel 4.2 站点,所以我要安装 Mcrypt:
sudo apt-get install php5.6-mcrypt
4) In order to get my mysql database up and running, I also had to install mysql.
4) 为了让我的 mysql 数据库启动并运行,我还必须安装 mysql。
sudo apt-get install php5.6-mysql
And of course after all that, I had to re-import the database contents from the file I'd exported before upgrading the Homestead box.
当然,毕竟,在升级 Homestead 框之前,我不得不从导出的文件中重新导入数据库内容。
Note that if you ever destroy and recreate the Homestead box, you will need to repeat all these steps again.
请注意,如果您曾经销毁并重新创建 Homestead 盒子,您将需要再次重复所有这些步骤。