If you’re trying to shift your PHP version from one to another but you’ve encountered an error, then you’re not alone.
Many of US have!
Well, it can be regarding the core architecture or with any extension, depending on the specifics.
Hence today, I’m going to share my experience when I simply tried to shift PHP from one version to another and encountered an error.
It was regarding the prerequisites of the PHP version and the extensions that are necessary for your project setup.
But, first thing’s first.
First, you will have to check the .env.php file in project/etc/env.php.
Then, check the database name and host.
Once you’re done with that, then you will need to check the PHP version and if the extensions are missing.
If that is the case, then simply install the missing extensions.
However, sometimes you get an error like the Fatal error.
That is a call for undefined function mcrypt_encrypt().
This might be due to the missing mcrypt extension in your current PHP version.
To resolve this issue, follow the steps given below.
- Install extension: sudo apt-get install php7.1-mcrypt
- Restart Apache2: sudo systemctl restart apache2 / sudo service apache2 restart
- Try loading the project.
There might be another issue which happens when you shift from PHP 7.2 to 7.1 using a2enmod.
This happens when there is a missing command while shifting the version.
Therefore, if you want to properly shift from PHP 7.2 to 7.1, try the following commands:
- sudo a2dismod php7.2
- sudo a2enmod php7.1
- sudo systemctl restart apache2 OR sudo service restart apache2
- sudo update-alternatives –set php /usr/bin/php7.1
- After that, check phpinfo.php and try loading your project again.
This should answer your question and help you to resolve any error that you might’ve encountered.
All I want to say in the end is, Happy Coding!