2
votes

I am trying to get an old Laravel 4.1.x app up and running again so that it can be modernized. This requires an environment with PHP 5.6 and the Mcrypt extension. I have installed Homestead 9.0.3 (the latest stable version). Within the VM, I have set the PHP version to 5.6

sudo update-alternatives --config php

I have then installed the php-mcrypt extension

sudo apt-get install php5.6-mcrypt

I am now able to create a new Laravel 4.1.x project, which is a process that requires Mcrypt to complete, so we're certainly getting somewhere:

composer create-project laravel/laravel="4.1.*" myAppName

However, when I browse to the webpage for myAppName, I see the message:

Mcrypt PHP extension required.

I have also tried steps that are usually recommended for this problem, ie:

sudo ln -s /etc/php/5.6/conf.d/mcrypt.ini /etc/php/5.6/mods-available/mcrypt.ini
sudo phpenmod mcrypt
sudo service php5.6-fpm restart

But I still get the same message in the browser.

What step have I missed?

2
You were able to create the project so that suggests mcrypt is working with your PHP CLI but not with PHP-FPM. Have you linked the mcrypt config file in your /etc/php-fpm directory?Calum Halpin
If the PHP version installation is working, maybe you just need to run 'php56' inside vagrant ssh.Flávio Silveira

2 Answers

2
votes

With homestead v9 you should be up and running with php5.6 out of the box as stated in here, but unfortunately it is not your case, and I understand that...

Old packages were not installed by default (php5.6-mcrypt), as you mentioned and they should be added by hand via: sudo apt-get install php5.6-mcrypt

After that all packages are ready, up and working, especially php5.6-mcrypt.

The root of your problem is in multiple site definitions under your homestead.yaml. Most probably some of them are overlapping and your nginx is referring to the wrong resource/site_definition, and wrong paths.

Therefore you might think some strange php versions or routes are run/executed.

You can verify that, by deleting some/all of them, leaving the only one important for you - in (/etc/nginx/sites-enabled/...).

Of course please do that inside the container and issue sudo service nginx restart, afterwards...

All of your problems should be gone after that.

If something goes wrong. You could easily recover your current installation to current state using vagrant destroy and vagrant up afterwards, cause all is saved in Homestead.yaml.

In my installation Homestead v9 is running with php5.6 on laravel 4.1 without any problems...

Hope it helps @jsm...

1
votes

Because all the PHP versions installed on homestead you need to set the PHP version for a site in the Homestead.yaml.

First check what version the server is running with phpinfo();

Check the file /etc/nginx/sites-enabled/homestead.test and look for this line:

fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;

If you didn't set the php version on the sites list, this file will be pointing to the php7.3.sock. In this case the version 5.6 has mcrypt installed, but 7.3 don't.

You can just replace the line

fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

for

fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;

and then reload nginx with sudo nginx -s reload.

Or set the php version on Homestead.yaml:

sites:
- map: homestead.test
  to: /home/vagrant/code/public
  php: "5.6"

And then run vagrant provision, it will change the nginx configuration for PHP 5.6.