I moved to a new hard drive, and copied everything necessary to the best of my knowledge. I try to load any page that requires my PDO Database object and it crashes.
This is the error:
Fatal error: Uncaught Error: Class 'PDO' not found in /var/www/the_website.net/config/DB.php:20 Stack trace:
#0 /var/www/the_website.net/public_html/index.php(16): DB->__construct()
#1 {main} thrown in /var/www/the_website.net/config/DB.php on line 20
This is the line (and few surrounding lines) in question in DB.php:
public function __construct($username='username', $password='supersecretpassword', $host='localhost', $dbname='database', $options=[])
{
$this->isConnected = true;
try {
$this->db_data = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8",$username, $password, $options);
$this->db_data->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->db_data->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (PDOException $e) {
throw new Exception($e->getMessage());
}
}
It's just the creation of the object.
Here are my enabled modules in /etc/php/7.2/apache2/php.ini (I just did them all because nothing was working anyway):
extension=openssl
extension=pdo_firebird
extension=pdo.so
extension=pdo_mysql
extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
Here is the result of php -m
root@HAL4:/etc/php/7.2/apache2# php -m
[PHP Modules]
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO <-- Still doesn't work
pdo_mysql <-- Nope. Still not working.
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
I have run phpenmod for both modules.
My former hard drive was running php 7.0. Now I'm running php 7.2.
Running <?php phpinfo(); ?>
in a test page tells me:
Configuration File (php.ini) Path /etc/php/7.0/apache2
Loaded Configuration File (none)
Scan this dir for additional .ini files /etc/php/7.0/apache2/conf.d
Additional .ini files parsed (none)
Update I removed the php7.0 modules completely from /usr/lib/apache2/ so now everything is php7.2. My phpinfo() file displays the correct paths:
Configuration File (php.ini) Path /etc/php/7.2/apache2
Loaded Configuration File /etc/php/7.2/apache2/php.ini
Scan this dir for additional .ini files /etc/php/7.2/apache2/conf.d
Still getting the Class'PDO' not found
error, however.
What else can I check? Why are they not loading?