I badly need help, I just want to say first that I am a newbie with web server. My boss was asking to me to upgrade our web server to the latest version Ubuntu 20.04 LTS as the old was running with 14.04. I've installed the distribution and a LAMP Stack on my desktop as I would like to try it first with my own computer before touching the server. I've installed Apache2, PHP 7.4.3 and mySQL 8.0 however the versions running on the old server are PHP 5.x and MySQL 5.x. I copied all the files over from /var/www/ and the Apache configuration files from /etc/apache2 then created a SQL dump and migrated to the the new mysql database (I made sure that permissions are the same with the old server). However, every time I open localhost in a browser, I see this error message:
Database Error: Unable to load Database Driver: mysqliUpdate: Database error has been sorted out by the steps provided by Matigo below.
Here is my new situation, I still can't access my website as localhost as it only shows the word "Error"
Error log says:
Failed to read session data: user (path: /var/lib/php/sessions) in /var/www/kssp/libraries/joomla/session/handler/native.php on line 194
I really appreciate the help guys!
btw this how the session dir looks like: not sure if i need to do chmod for this.
drwxr-xr-x 3 root root 4096 Feb 8 22:55 modules drwx-wx-wt 2 root root 4096 Mar 27 2020 sessions
Issue Resolved:
Steps taken:
- Uninstall - Reinstall LAMP Server
- Verified if all php-modules were enabled
- Created mysql database backup from old server
- Recreated mysql database in the new server
- Recreated database user pass to the new server and made sure it matches - Allowed Override All on Apache2.conf
- Enabled rewrite module
Everything on the website now looks exactly the same with my localhost/server.
Next is to map the ip address and point the A record.
I'm happy that this has been sorted out, thanks to Matigo for enlightening me with the steps.
101 Answer
Based on the persistent error, the issue (in my mind) comes down to one of a few cases:
php-mysqlis not installed, or is not the correct version for PHP 7.4- The
php-mysqlndhelper package is not installed (this generally comes withphp-mysql, so should not require attention) - Apache has not been restarted since updating PHP
- The
mysqliextension is commented out in itsinifile
So, let's do some testing by creating a dummy PHP file in your web root that calls the phpinfo() function:
- Open Terminal (if it's not already open)
- Create a dummy PHP file in the web root:
Notes:sudo vi /var/www/testing.php
• Feel free to use any other editor that you prefer. The use ofviis more about muscle memory than an implicit endorsement for the editor.
• Be sure to change/var/wwwto the actual document root location for - Paste this into the new file:
<?php phpinfo(); ?> - Save the file
- Open your browser and access . This should give you a PHP information page that looks something like this:
- Scroll down (or use the Find function) to locate the section titled
mysqli. It should look something like this:
Now comes the "fun" part.
If you see a blank page when visiting testing.php ...
⇢ PHP is not configured correctly. For simplicity's sake, remove and re-install:
sudo apt install --reinstall php libapache2-mod-php php-mysqlThen restart Apache:
sudo service apache2 restartIf you see the PHP Info page, but nothing for mysqli ...
⇢ mysqli is either not installed or not configured correctly.
Confirm that
mysqlifor PHP 7.4 is installed by opening a terminal (or using the current one) and typingsudo apt install php7.4-mysql(Note that we are specifically calling the package for 7.4 here. This should not be necessary, but we want to be 100% certain it's the correct version for your PHP installation)If everything is installed properly, you will see a message like this:
Reading package lists... Done Building dependency tree Reading state information... Done php7.4-mysql is already the newest version (7.4.3-4ubuntu2.4). 0 to upgrade, 0 to newly install, 0 to remove and 2 not to upgrade.Confirm that the
mysqli.inifile exists and is configured correctly by opening a terminal (or using the one that's currently open), navigating to theconf.ddirectory for PHP and Apache, and listing MySQL-related files:cd /etc/php/7.4/apache2/conf.d ll *mysql*You should see something like this:
lrwxrwxrwx 1 root root 39 5月 9 2020 10-mysqlnd.ini -> /etc/php/7.4/mods-available/mysqlnd.ini lrwxrwxrwx 1 root root 38 5月 9 2020 20-mysqli.ini -> /etc/php/7.4/mods-available/mysqli.ini lrwxrwxrwx 1 root root 41 5月 9 2020 20-pdo_mysql.ini -> /etc/php/7.4/mods-available/pdo_mysql.iniIf you do not see these files, then
php-mysqlwas not correctly installed. Let's try again:sudo apt install --reinstall php-mysqlOpen the
20-mysqli.inifile and ensure the contents of the file matches this:; configuration for php mysql module ; priority=20 extension=mysqli.soRestart Apache:
sudo service apache2 restartIf everything matches, open the
mysqlnd.inifile. This file must be loaded beforemysqli, so it will probably be prefixed with10-in the directory. Ensure theextension=mysqlnd.soline does not have a;in front of it.
If everything so far has matched your configuration ...
⇢ The problem is most likely in the application code itself and may need to be examined by a developer familiar with the system to make the changes necessary to work with the newer technology stack.
Rarely do I see Apache installations require this much effort unless you're migrating something with really obscure requirements. Most LAMP stacks are painfully simple, as a lot of people have made the tools a lot easier to use over the last decade or so.
Hopefully something here will help you resolve the issue.
2