How to roll back PHP version in Vagrant and Homestead? - php

So, my company is using PHP with Laravel for software development for clients. I am new to the company and setting up a newer Macbook with VirtualBox, Laravel using Homestead, and Vagrant.
I have gotten everything set up to be able to create local files and have them also tie into the VM, but anytime we try to open the pages using our local host, it gives us the error that "Laravel requires the Mcrypt PHP extension".
I have migrated all of our in-house files over to my local machine to be able to open them locally, but I can't get them to open even with being able to see them in the terminal. It works fine on the other developer's Macbook, although he is using an older version of both PHP and Laravel.
My question, which I cannot find a relevant question about, is can I install an older version of laravel and PHP to be able to force my VM project to open only with PHP version 7.0? I found some posts that indicate that mcrypt is no longer supported on PHP 7.1+.
Please include any relevant information you know of. We have been beating our heads against this issue all day yesterday and today. I'm sorry if this post seems noob-ish. I'm just not figuring it out.
***EDIT:
We got it figured out today. We had to force our project into PHP 7.0 and finally got it working. We deleted the entire original Laravel installation and reinstalled using this tutorial: https://medium.com/#gdiasdasilva/creating-a-homestead-box-with-php-7-0-aaa72fb0e297
Thank you guys for your responses. Thankfully after two days, we worked our way through the issue. The biggest issue was trying to allow the project, which was created on another machine using a different version of PHP, to open and run on my machine. Not an issue I had seen anywhere before. To be fair, this is my first time ever working with Laravel. I have a background in ASP.NET MVC 5 and this is an adjustment on getting the correct dependencies.
Again, thank you all for your responses!***

You can specify the PHP version in the Homestead.yaml file:
sites:
- map: homestead.test
to: /home/vagrant/code/Laravel/public
php: "7.0"
After making this change you will need to re-provision Homestead:
vagrant reload --provision
See the Multiple PHP Versions section from the documentation.

Related

Php version differs between homebrew and localhost

I try to update my php to 8.0 using homebrew. The update worked fine. The “php -v” shows that the actual version is 8.0.14. However when I open my localhost and go to “phpinfo.php” it shows the old version 7.4.22. Obviously my server still uses the old one. How to fix this? How to update the server version. I saw several post about similar problem, but the solutions offered didn’t work for me… I’m using Mac.
Thanks
So after long searching I finally found this step-by-step tutorial.
https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions
What I did:
I added apache to my server;
I added php to my server (now I no longer need XAMPP);
I followed the step by step configuration to connect apache to php (through updates in httpd.conf file).

I have developed am application using PHP7 but on the server there is PHP5 and we cannot upgrade the PHP there

Please help me, I have developed an application using Yii2 Framework which requires PHP5.6 or greater, and while deployment of the application on the test server I have noticed that on the test server we are using PHP5.5, So please tell me what can I do? The test server is running Ubuntu.
(Minimum requirement of Yii2 is PHP5.6 and we are using PHP5.5)
Thank You.
if I recall correctly, PHP 5.5.X and 5.6.X are not that different. So if you can deploy your application and it runs properly, you should be fine. If you are using composer, it might be harder (or impossible) to spoof your PHP version, though.
My two cents:
You tagged AWS (and therefor probably EC2), so why don't you just update your PHP version? Why don't you run your application on PHP 7.X anyway? It is a great improvement - performance-wise.
You can try a few things...
1) Do you need to have the dev modules from Composer on the test server? If not do a composer install —no-dev
2) Another switch worth trying on the test server is “--ignore-platform-reqs” I don’t recommend it and even though composer install the files the application might not work.
3) If the above isn’t a fix for you, modify your Composer file to put in the constraints of your environments, change your local environment to match the test server, and re-factor the application if necessary. I’d do that instead of rewriting a whole app in Yii1.
You might want to edit your question and add the information about your composer.json file. Do you commit the composer.lock file to source control?
Additionally, not wise for your company to use anything older than PHP 5.6. And PHP 5.6 will have security support ended in Dec 2018. http://php.net/supported-versions.php
Read the following PHP documentation linked below, particularly the backward incompatibility changes and deprecated features. If you use any of those, you need to change your code. If you don't, then you should be fine. You need to test it.
http://php.net/manual/en/migration56.php

PHP Install on IIS 7, no test results

I am trying to install PHP on my IIS web server running version 7.0. I downloaded the php-7.1.8 Non Thread Safe for Windows 64. I then procceded to follow the steps found here: https://www.howtogeek.com/50432/how-to-install-php-on-iis-7-for-windows-server-2008/.
I had no issues with the install but when it came to the last step of creating the test PHP page and launching, instead of getting the results, i'm being asked to Open or save the file??
I've also tried putting this into a live website and accessing it outside the web server. When I try this I receive a 500 - Internal Server Error.
I had tried this about a year or two ago and got frustrated, so I gave up and have retried today but experiencing about the same result. Don't know what other information would help, but i'm willing to provide what's necessary. Thank you for any help.
After continuing research I ended up using the Windows Installer version (https://www.microsoft.com/web/platform/phponwindows.aspx) and then went back through the configuration steps of the php.ini file.

Ubuntu server 11.10 and PHP 5.2 for use with Drupal 6

I'm trying to figure something out:
I am using Ubuntu server 11.10 virtualized on Win7 (I don't think that matters but more info is better than less) to work on a Drupal 6 website I inherited and need to make significant changes to.
I want to set up a development copy of this Drupal website on my Ubuntu server so I can work without worrying about torching the production website.
I successfully got the production files downloaded and onto my machine, I got the production MySQL database exported and imported into the dev MySQL server, and I set up a symbolic link from the directory /home/myname/thewebsite.com to /var/www/thewebsite.com so I can easily access it.
When I got the website they didn't know the admin password so I dug around online and reset it in the dev db using phpmyadmin and finally log in.
When logging in and poking around the site there are lots of errors, which when googled lead me to believe that PHP 5.3 is causing them and that there are some modules in use that only work with PHP 5.2
After looking around a lot online and on stackoverflow there seems to be no easy way to install PHP 5.2 on Ubuntu Server 11.10. With no packages for 5.2 available through apt-get or aptitude what should/can I do?
1) Install 5.2 from source - how do I get it to interface with MySQL and Apache2? Also, I've never installed anything significant from source. Is there a walkthrough?
2) Replace the repositories with old ones? Will this work on 11.10? The newest instructions I found were for 10.04
3) Use already built PHP 5.2 packages for Ubuntu? Couldn't find these
4) Pay someone who knows more to do it for me? (Just kidding, this isn't really an option...)
Cheers and thanks for your help!
PHP dropped support for 5.2 in August 2011; operating system providers such as Ubuntu will not supply a version that is out of support, so you absolutely won't get an official copy of PHP 5.2 on the current version of Ubuntu (or any other OS).
If you're running an older version of Ubuntu (eg 10.04), you might be able to do it; it would still be a downgrade, because PHP 5.3 has been the default version for quite a long time now.
If you're on a newer version of Ubuntu, ie 11.10 as you state, it is going to be a problem for you.
The Drupal developers dropped the ball badly on this one. I guess it was because Drupal 7 tool so long to finish; they were expecting D7 to be out much sooner, and so they never bothered fixing up D6 to work with PHP5.3. As it turned out, this was a big mistake, because in fact D7 still wasn't officially released when PHP dropped support for 5.2.
But even so, they should have fixed it, because they're still officially supporting Drupal 6, so they need it to work with the current version of PHP. This is definitely Drupal's problem, not PHP's, Ubuntu's or yours.
But you still need to deal with it.
I found this question over on AskUbuntu.com, which gives an answer applicable to 11.04. It isn't quite 11.10 you were asking for, but it it a lot more recent than the best you'd found, so it might be helpful.
Alternatively, you could research exactly what it is about Drupal6 and your specific modules that doesn't work in PHP5.3. The language differences between 5.2 and 5.3 that can break things are not big, so I would expect any code changes required to be fairly small. You might find you can fix the code yourself. And maybe even submit the changes to the community -- Drupal is open source, after all.
Another tack you could take is to consider whether this saga represents an opportunity for you to move the site to Drupal 7?
This may or may not be feasible, depending on the modules you're using, etc, but if it is possible, it will solve the problem, because D7 is of course fully compatible with PHP5.3.
And just to cheer you up, I'll close by mentioning that PHP are on the verge of releasing PHP 5.4. Hopefully the Drupal devs will be more on the ball this time.

PHP has encountered an Access Violation at 77FCAFF8

I am running a PHP site that uses Ajax and jQuery as well. The site will run fine for quite some time, and suddently my pages (and ajax-retrieved sub-pages) comes back with the message
PHP has encountered an Access Violation at 77FCAFF8
It seems that rebooting the server corrects the issue. Running PHP Version 5.1.6 (Windows NT 5.0 build 2195). I did a some searching on here and some other sites, and there seems to be no fix..
URL REMOVED
UPDATE:
I think I'm on to something.. will get back to you.
UPDATE
After reviewing the IIS setup, i noticed there was no Handler Mapping setup for the website. This, of course begs the question - how did it ever work in the first place, when it was originally setup this way!? I added the handler mapping and it seems to be Okay so far.
UPDATE
The problem popped its heads out again this morning after 36 hours without encounering it. Back to the drawing board.
UPDATE
We ended up just moving the site to a secondary web server where we were able to upgrade PHP without an issue.
This is a PHP issue somewhere. You could spend some time narrowing down which function you're using that is causing the problem. I would instead upgrade to a newer version of PHP. If still no luck, try a slightly older version. There have been significant changes with version 5.3.2.
After some research I think this may be the solution (Taken from http://bugs.php.net/bug.php?id=28929 ):
[2010-06-11 15:12 UTC] in2ishun at yahoo dot com
***************** SOLUTION!!!!
I realize this issue is AGES old, but it still manages to be the top hit on Google searches as of now (6/2010).
I fixed my own instance of seeing this error. W2k3, IIS6, PHP 5.2.6, MySQL 5.1.
The problem is in the pathing. When I used the MSI installer for MySQL without doing an "advanced" installation (where I could manage the install details), it added a path to the system environment that contained spaces. Even after changing the path environment to use the Windows short-name location of the mysql bin directory, it still didn't work.
The solution was for me to reinstall mysql and set the default installation path to just off the root (e.g. C:\mysql). Once I did that the error went away and my app started working.
There are a number of sites with a variety of potential solutions to this issue and several of them mentioned paths and the "libmysql.dll" file (in the "bin" directory of your mysql installation).
If this helps you solve your problem, consider leaving a comment here so others can see that it works.

Categories