I have a virtual website in an ubuntu 18.04 server that is written in Laravel9 and it needs php version 8.0.2 or higher. The error looks like this in the browser:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2".
In the system I have PHP 7.4.29 (cli) but can't change that due to other virtual sites who need 7.4.
How do I get php 8.1 to the Laravel9 site so it works?
My Answer:
of 8.0.2 or higher, but your platform is running PHP 7.2.24-0ubuntu0.18.04.10.
To upgrade your PHP version to 8.1 for this specific virtual website, you can follow these steps:
1. Add the ondrej/php repository to your system:
sudo add-apt-repository ppa:ondrej/php
2. Update the package list:
sudo apt update
3. Install PHP 8.1 and the necessary extensions:
sudo apt install php8.1 php8.1-common php8.1-cli php8.1-fpm php8.1-mbstring php8.1-xml php8.1-mysql php8.1-curl php8.1-zip
4. Switch to the newly installed PHP version:
sudo update-alternatives --set php /usr/bin/php8.1
sudo update-alternatives --set phar /usr/bin/phar8.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.1
sudo update-alternatives --set phpize /usr/bin/phpize8.1
sudo update-alternatives --set php-config /usr/bin/php-config8.1
5. Restart your web server to apply the changes:
sudo systemctl restart apache2
After following these steps, your virtual website should now be running on PHP 8.1. You can verify the PHP version by running `php -v` in the terminal.
Rate this post
5 of 5 based on 5871 votesComments