If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Connection between PDO and Php-fpm

Started by amardeep, May 01, 2023, 12:06 AM

Previous topic - Next topic

amardeepTopic starter

The server has Nginx, which directs requests to both Apache and php-fpm. On the site running on Apache, phpinfo() shows that PDO drivers are connected to MySQL. However, on the site running on php-fpm, there is no connection to the PDO driver as displayed by phpinfo(). This issue is observed on ArchLinux operating system.
How can we resolve the problem of php-fpm not being able to connect the PDO driver?

  •  


slurinkappala

Place the 'pdo_mysql.ini' file containing 'extension=pdo_mysql.so' in the '/etc/php.d/' directory. This directory is automatically scanned by php-fpm for configuration files. Do not modify the 'php.ini' file.
 
Make sure that the file '/usr/lib64/php/modules/pdo_mysql.so' exists. If it does not, we will need to come up with another solution.

Additionally, check the following files for possible errors:
- /etc/php-fpm.conf
- /etc/php.ini
- /etc/php-fpm.d/www.conf
  •  

Aletletle

There's a lack of clarity regarding the nginx <-> apache <-> php-fpm bundle.
Have you set up Apache using modphp or php-fpm? And is Nginx functioning as a proxy server?
  •  

Zurgerok

I installed mysql-8-0 from a zip archive under Windows. The procedure remained the same: unpacked and created a folder named /T/DATA/MYSQL. To initiate the launch I used the command bin/mysqld --datadir=/T/DATA/MYSQL for stopping the activity bin/mysqladmin shutdown -u"xroot".

Then, in the command line, I navigated to c:\T\usr\mysql80 and ran this code: bin\mysqld --initialize --user=root --datadir=/T/DATA/MYSQL. It generated a temporary password for root@localhost: cpAg2wgLsY/! and saved it in the file /T/DATA/MYSQL/xx.err. After logging in using the password, I modified some user settings by running these lines of code: ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'; CREATE USER 'xroot'@'localhost' IDENTIFIED BY '';

GRANT ALL ON *.* TO 'xroot'@'localhost'. When I tried to create a connection using my old MySQL-WorkBench version 5.2.28, it didn't work. I encountered an issue where the authentication method requested by the server was not supported by the client. To resolve this, I looked up the solution and entered this code:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'. Additionally, I created a new file named my.cnf under c:\T\usr\mysql80\ with this line of code [mysqld] default_authentication_plugin=mysql_native_password.

I restarted the system even)) and it worked. I haven't made any changes since then.
  •  

gobemype

I would approach the issue of php-fpm not being able to connect to the PDO driver on an ArchLinux server with a detailed step-by-step plan.

1. Check php.ini Configuration: First, I would verify the php.ini configuration file for the php-fpm pool. This can typically be found at /etc/php/php.ini or the specific configuration directory for php-fpm. Within the php.ini file, I would confirm that the pdo_mysql extension is enabled by ensuring the line "extension=pdo_mysql.so" or "extension=pdo_mysql.dll" is present and uncommented. If it's missing or commented out, I would add or uncomment it and save the file.

2. Verify php.ini Location: In some cases, php-fpm might use a different php.ini file compared to the Apache server. I would ensure that the correct php.ini file is being used by checking the php-fpm pool configuration file for the "php_admin_value[open_basedir]" directive, which specifies the base directory for the php.ini file. I would then verify that the pdo_mysql extension is properly loaded in this php.ini file.

3. Restart php-fpm Service: After making any changes to the php.ini file, I would restart the php-fpm service to apply the new configuration by running the command:
 
 
sudo systemctl restart php-fpm 

4. Check PHP-FPM Logs: If the issue persists, I would review the PHP-FPM error log for any relevant error messages. The log file location can be found in the php-fpm pool configuration file under the "php_admin_value[error_log]" directive. Examining the log could provide insight into any specific errors related to the PDO driver.

5. Verify File Permissions: It's important to ensure that the PHP-FPM process has appropriate permissions to access the necessary files and extensions. I would check the ownership and permissions of the php-fpm configuration files, the pdo_mysql extension file, and any related directories to confirm that PHP-FPM has the required access.

6. Test PHP-FPM Configuration: To validate the changes, I would create a simple PHP script that uses the PDO extension to connect to a MySQL database and execute it on the site running on php-fpm. This can help identify whether the PDO driver is indeed functioning after the configuration adjustments.

7. Additional Troubleshooting: If the problem persists, I would further explore potential issues such as conflicting software components, system environment variables, or any custom configurations that might be impacting the connection to the PDO driver.

By following these detailed steps, I aim to methodically address the issue and ensure that php-fpm can successfully connect to the PDO driver for MySQL on the ArchLinux server.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...