Hi, I've installed PHP, Apache, and MariaDB on FreeBSD, and everything seems to be working fine—except that I can’t get WordPress to connect to the database. Here are the steps I’ve taken so far:
Step 1: Install and Configure Apache and PHP
I added the following line to /usr/local/etc/apache24/httpd.conf:
Then, I added these lines to /usr/local/etc/apache24/Includes/php.conf:
I also created a PHP test file at /usr/local/www/apache24/data/index.php:
After restarting Apache with sudo service apache24 restart, both Apache and PHP worked fine.
Step 2: Install and Configure MariaDB
I can create and manage databases without any issues. I also installed phpMyAdmin, which works well for database management:
The database user is wpuser, with a database named wordpress and password myfreebsd. I also tried the root user, but WordPress still doesn’t connect.
Now I can see wordpress shows setup before rename wp-config-sample.php to wp-config.php:
I’ve tried a lot of troubleshooting steps but haven’t been able to solve it. Since this seems more related to FreeBSD than WordPress itself, I thought I’d ask here. Any help would be greatly appreciated!
P.S:
I've attached phpinfo full screen.
Any help would be greatly appreciated!
Step 1: Install and Configure Apache and PHP
Code:
sudo pkg install apache24
sudo sysrc apache24_enable=yes
sudo service apache24 start
sudo pkg install php82 mod_php82 php82-mbstring php82-zlib php82-curl php82-gd php82-mysqli php82-pear-MDB2_Driver_mysqli
I added the following line to /usr/local/etc/apache24/httpd.conf:
ServerName localhost
Then, I added these lines to /usr/local/etc/apache24/Includes/php.conf:
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
I also created a PHP test file at /usr/local/www/apache24/data/index.php:
PHP:
<?php
phpinfo();
?>
After restarting Apache with sudo service apache24 restart, both Apache and PHP worked fine.
Step 2: Install and Configure MariaDB
Code:
sudo pkg install mariadb105-server mariadb105-client
sudo sysrc mysql_enable=yes
sudo service mysql-server start
mysql_secure_installation
I can create and manage databases without any issues. I also installed phpMyAdmin, which works well for database management:
The database user is wpuser, with a database named wordpress and password myfreebsd. I also tried the root user, but WordPress still doesn’t connect.
Now I can see wordpress shows setup before rename wp-config-sample.php to wp-config.php:
Step 3: Configure
I edited wp-config.php (renamed from wp-config-sample.php) with the following database settings:
PHP:
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'myfreebsd' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
Issue
When I try to access WordPress, I get the error: “Error establishing a database connection.”I’ve tried a lot of troubleshooting steps but haven’t been able to solve it. Since this seems more related to FreeBSD than WordPress itself, I thought I’d ask here. Any help would be greatly appreciated!
P.S:
FreeBSD version: FreeBSD 13.3-RELEASE-p3 FreeBSD 13.3-RELEASE-p3 GENERIC amd64
PHP version: PHP 8.2.24
Wordpress version: 6.6.2
I've attached phpinfo full screen.
Any help would be greatly appreciated!