Report this

What is the reason for this report?

Can't Connect Prestashop with multi php versions

Posted on February 28, 2021

Hello, In my Droplet i have php 7.4. I installed 7.3 with https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-ubuntu-18-04-fr

When I use a 7.4 Prestashop find a database, but when i change it to php 7.3 I have this erreur : Database Server is not found. Please verify the login, password and server fields (DbPDO)

You help please. Thx



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @khalid94.

Are you sure you have the php-mysql extension? Make sure you type in the following inside of your droplet

sudo apt-get install php7.3-mysql

If it’s not installed, select Y and install it.

That should help with your issues.

Hi @KFSys Thank you for answer. My sql it’s OK .

code

sudo apt-get install php7.3-mysql Reading package lists… Done Building dependency tree Reading state information… Done php7.3-mysql is already the newest version (7.3.27-9+ubuntu20.04.1+deb.sury.org+1). 0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.

code

But he don’t work. but if I change php site to 7.4 it work’s.

you can see my phpinfo in http://hb-plomberie-chauffage.fr/phpinfo.php

Thank you

The issue you’re encountering with PrestaShop and PHP 7.3 is likely due to a missing or misconfigured PHP extension that PrestaShop requires to connect to the database. Here’s how to troubleshoot and resolve the issue:


1. Verify PHP 7.3 Installation

Ensure that PHP 7.3 is installed correctly and includes all the necessary extensions for PrestaShop.

  1. Check installed extensions for PHP 7.3:
php7.3 -m
  • Look for the following modules:

    • pdo
    • pdo_mysql
    • mysqli
  • If any are missing, install them:

sudo apt install php7.3-mysql
sudo systemctl restart php7.3-fpm

2. Update Apache Configuration

When switching between PHP versions, ensure Apache is using the correct PHP version.

  1. Disable PHP 7.4 and enable PHP 7.3 for Apache:
sudo a2dismod php7.4
sudo a2enmod php7.3
sudo systemctl restart apache2
  1. Check which PHP version Apache is using:
php -v

3. Verify PrestaShop Configuration

Make sure PrestaShop is using the correct database connection details.

  1. Open the app/config/parameters.php file in your PrestaShop installation directory:
nano /path/to/prestashop/app/config/parameters.php
  1. Confirm the database credentials (hostname, username, password, database name) match your database setup.

4. Debugging the Database Connection

If the error persists:

  1. Test the database connection using a simple PHP script:
<?php
$pdo = new PDO('mysql:host=127.0.0.1;dbname=your_database_name', 'your_username', 'your_password');
echo "Database connection successful!";
?>
  1. Save this as test_db.php in your web root and access it in your browser. If it fails, it indicates an issue with your PHP 7.3 MySQL extension.

5. Check MySQL Server Logs

Review the MySQL logs for any clues:

sudo tail -f /var/log/mysql/error.log

6. Confirm PHP-FPM Pool Configuration

If you’re using PHP-FPM with Apache, ensure the configuration for PHP 7.3 is correct.

  1. Check the PHP-FPM pool configuration:
sudo nano /etc/php/7.3/fpm/pool.d/www.conf

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.