简体   繁体   English

Homestead安装了PHP7,但我需要PHP5

[英]Homestead Installed PHP7 but I need PHP5

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 instructions I was following had optional options 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. 我已多次删除VirtualBox框并重新加载它。
  • I tried installing v0.3.3 of the box based on one suggestion. 我尝试根据一个建议安装盒子的v0.3.3。 (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. (我也相应地更新了homestead.rb脚本。)有一次,在使用php7.0-fpm: unrecognized service安装过程中出现php7.0-fpm: unrecognized service和配置的站点返回502 Bad Gateway错误。
  • After reinstalling with v.0.4.0, it has started "running" as I described (serves the sites as expected, etc.), but with PHP 7. 在使用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. :) Laravel,Vagrant,Homestead,所有这些都让我头疼。 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. 任何建议或替代研究这个问题的途径将不胜感激。

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: 我也经历过这个问题,我通过安装一个旧的宅基地v0.3.3解决了它,我使用了旧版本的宅基安装程序,所以我建议你删除当前的v0.4.0框并删除你的宅基文件夹然后这样做:

$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.8 it works fine. 然后从git下载旧版本的Homestead安装程序,我正在使用v2.1.8它工作正常。 Enjoy php 5.6 :) 享受PHP 5.6 :)

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,各种消息来源称可以通过在指定PHP版本的.yaml文件中添加一行来实现。

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. 当我尝试时发生的事实是我得到了502 CGI网关错误。 Here is a summary of the steps I had to take to fix it: 以下是我必须采取的修复步骤的摘要:

1) SSH into the Homestead virtual machine. 1)SSH进入Homestead虚拟机。

ssh vagrant@127.0.0.1 -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. 3)完成所有这些后,刷新您网站的网页,它现在应该可以正常工作。 In my case, because I was running a Laravel 4.2 site, I then to install Mcrypt: 在我的情况下,因为我正在运行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框,则需要再次重复所有这些步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM