1. 首先進入你下載的php的安裝包裏找到pdo_mysql文件夾。php
/usr/local/php-7.3.3/ext/pdo_mysql
ps:有些教程說從http://pecl.php.net/這個網站上下載pdo_mysql擴展,而後再編譯安裝。唉,兄弟啊,這個東西社區都不維護了,你還從上面下載個球球啊!!!!mysql
你們必定要避免這個坑啊!!!!!nginx
2. 執行phpize。sql
這裏要注意,你要使用本身要添加擴展的php的phpize。什麼意思呢?好比說你有php7 和 php7.3兩個php版本,你要把擴展添加進7php7.3,那麼你就須要使用php7.3的擴展,怎麼使用呢?自行百度吧。瀏覽器
phpize是用來擴展php擴展模塊的,經過phpize能夠創建php的外掛模塊
3. 配置擴展信息php7
./configure --with-php-config=/usr/local/php/bin/php-config // 這樣是不行的!!!!!
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql (php的安裝路徑,也就是php的可執行文件)
4. 編譯和安裝php-fpm
make & make install網站
5. 修改php.ini文件spa
增長extension=pdo_mysql.so;.net
6. 重啓php-fpm
sudo kill -USR2 進程號
遇到問題及解決方法:
1. nginx的錯誤日誌
[error] 6910#6910: *1278203 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 218.107.211.81, server: caojiangjiang.qhrm.chunmiantest.qufenqi.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9800", host: "caojiangjiang.qhrm.chunmiantest.qufenqi.com"
2. php-fpm的錯誤日誌
[18-Mar-2019 19:52:29] WARNING: [pool www] child 24699 exited with code 127 after 5484.614486 seconds from start [18-Mar-2019 19:52:29] NOTICE: [pool www] child 23246 started
3. 瀏覽器顯示
502
4. make test顯示
@'localhost' (using password: NO) SKIP PDO MySQL Bug #41698 (float parameters truncated to integer in prepared statements) [tests/bug_41698.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks future queries) [tests/bug_41997.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #42499 (Multi-statement execution via PDO::exec() makes connection unusable) [tests/bug_42499.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #43371 (Memory errors in PDO constructor) [tests/bug_43371.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #44454 (Unexpected exception thrown in foreach() statement) [tests/bug_44454.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #44707 (The MySQL PDO driver resets variable content after bindParam on tinyint field) [tests/bug_44707.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #45120 (PDOStatement->execute() returns true then false for same statement) [tests/bug_45120.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon) [tests/bug_50323.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #51670 (getColumnMeta causes segfault when re-executing query after calling nextRowset) [tests/bug_51670.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't always work) [tests/bug_61207.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE) [tests/bug_61411.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #61755 (A parsing bug in the prepared statements can lead to access violations) [tests/bug_61755.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP Bug #74376 (Invalid free of persistent results on error/connection loss) [tests/bug_74376.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP PDO MySQL PECL bug #1295 (http://pecl.php.net/bugs/bug.php?id=12925) [tests/bug_pecl_12925.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) SKIP PECL Bug #7976 (Calling stored procedure several times) [tests/bug_pecl_7976.phpt] reason: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) TEST 37/122 [tests/common.phpt] Warning: opendir(/usr/local/php-7.3.3/ext/pdo_mysql/ext/pdo/tests): failed to open dir: No such file or directory in /usr/local/php-7.3.3/ext/pdo_mysql/run-tests.php on line 922 ERROR: cannot open directory: /usr/local/php-7.3.3/ext/pdo_mysql/ext/pdo/tests Makefile:135: recipe for target 'test' failed make: *** [test] Error 1
其實這些問題的罪魁禍首就是在編譯的時候沒有編譯致使的,問題排查的方法很重要,基礎知識也很重要!!!
mysqlnd
另外能夠經過md5sum來檢測生成的pdo_mysql.so
使用 php -i 查看php在cli下面的詳細信息 // 查看程序可以正確執行
使用 php -m查看php 在cli下面加載了哪些模塊