MAC OS 上 php 連結到mysql時,出現錯誤訊息:SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available

Posted by on | | 0 意見
mac os 更新後,有些東西會出現error,尤其是server相關的設定檔,都變回出廠時的預設值了。

今天php連到mysql時,出現底下的問題:
The website encountered an unexpected error. Please try again later.
Error messagePDOException: SQLSTATE[HY000] [2002] No such file or directory in lock_may_be_available() xxxxxxxxxxxxxxx.

這問題,主要是pdo這個driver找不到mysql.sock
在 /private/etc/php.ini裡頭有個參數,指定到/tmp/mysql.sock:
pdo_mysql.default_socket=/tmp/mysql.sock

設定好,重新啟動apache即可
(# sudo apachectl restart)


ps:為什麼會在/tmp裡頭,我也不知,只是看到別人這樣設定,而我的/tmp底下也有個mysql.sock,試一下就成功了

升級到 mac os x 10.9 Mavericks,結果之前裝的opencc又不能跑了

Posted by on | | 0 意見
今天升級到 mac os x 10.9 Mavericks,結果之前裝的opencc又不能跑了,再來檢查一次,問題和之前的不一樣,只好紀錄下來:

1.執行phpize時,出現:
$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:      
Zend Module Api No:  
Zend Extension Api No:

解法:這要先執行底下一個指令,安裝xcode的東東:
$ xcode-select --install