在虛擬機上安裝了CentOs6.5在上面安裝了lnmp開發集成包(php7.1),對於以前沒有任何開發經驗的我來講,正常且安詳滴在集成環境上開發着優雅的小bug.php
然而我今天在Composer拉取代碼的時候,出現了問題:node
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/pdo/pdo_mysql.so' - /usr/local/php/lib/php/extensions/pdo/pdo_mysql.so: undefined symbol: pdo_parse_params in Unknown on line 0 Using version ^3.4 for sonata-project/admin-bundle ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 The requested package doctrine/orm (installed at v2.4.8, required as ^2.5) is satisfiable by doctrine/orm[v2.4.8] but these conflict with your requirements or minimum-stability. Problem 2 doctrine/orm v2.5.4 requires ext-pdo * -> the requested PHP extension pdo is missing from your system. doctrine/orm v2.5.3 requires ext-pdo * -> the requested PHP extension pdo is missing from your system. doctrine/orm v2.5.2 requires ext-pdo * -> the requested PHP extension pdo is missing from your system. doctrine/orm v2.5.1 requires ext-pdo * -> the requested PHP extension pdo is missing from your system. doctrine/orm v2.5.0 requires ext-pdo * -> the requested PHP extension pdo is missing from your system. Installation request for doctrine/orm ^2.5 -> satisfiable by doctrine/orm[v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.5.4]. To enable extensions, verify that they are enabled in those .ini files: /etc/php.ini /etc/php.d/curl.ini /etc/php.d/fileinfo.ini /etc/php.d/json.ini /etc/php.d/phar.ini /etc/php.d/zip.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.
這裏的問題好像在告訴我,PHP 沒有安裝 PDO擴展,然而我 經過 phpinfo() 閱覽了一下,PDO 是真實存在的,我非常懵逼。mysql
(關於擴展的小提示:一般在windows 上開發,經過 WAMP下直接在php.ini中啓用PDO就行(去掉;extension=php_pdo.dll前面的分號「;」),而linux上添加擴展 是以 .so 結尾的擴展名參考以下:https://blog.csdn.net/leedaning/article/details/46314521 經過上面的小提示,我發現我執行不了 phpize , 而後發現我並無openssl 我差點去執行了 php 的 openssl 源碼安裝 相關擴展,我這樣的行爲是愚蠢的,由於擴展是有的,而我如今發現我居然也沒有openssl 這個C源碼擴展。緣由是我不是編譯安裝的而是經過集成安裝的環境;若真的這麼作了我可能會發現新的問題,也甚者會越走越遠....)linux
因而 經過 php -m 我發現php的擴展並無 pdo mysqli ..., 而我執行 /usr/local/php/bin/php -m 發現居然有PDO MYSQLI 擴展,我非常懵逼!原來問題是這樣的 CentOs 其實安裝完成後 會自帶了一個php5.3的版本,我一直沒有發現。而我經過 Composer install 的時候其實走的是默認PHP版本,那默認PHP版本就是CentOs自帶的 5.3的版本,個人天吶!!!sql
經過以下命令才真正的使用了PHP7.1的版本,果真沒有任何問題!json
/usr/local/php/bin/php composer install
刪掉默認CentOs 自帶PHP5.3版本 vim
經過以下命令:匹配php,移除phpwindows
[root@localhost MerchantAdmin]# rpm -qa|grep php php-mbstring-5.3.3-49.el6.x86_64 php-cli-5.3.3-49.el6.x86_64 php-devel-5.3.3-49.el6.x86_64 php-common-5.3.3-49.el6.x86_64 php-5.3.3-49.el6.x86_64 php-bcmath-5.3.3-49.el6.x86_64 [root@localhost MerchantAdmin]# yum uninstall php-common Loaded plugins: fastestmirror, refresh-packagekit, security No such command: uninstall. Please use /usr/bin/yum --help [root@localhost MerchantAdmin]# yum remove php-common
刪除完以後執行了 php -v bash
[root@localhost MerchantAdmin]# php -v -bash: /usr/bin/php: No such file or director
因而可知 php 並無全局使用的權限,繼續修改添加全局目錄 php7
[root@localhost bin]# vim /etc/profile
添加以下後兩句便可
#set for nodejs export NODE_HOME=/usr/local/src/node-v8.9.4 export PATH=$NODE_HOME/bin:$PATH export PHP_HOME=/usr/local/php export PATH=$PATH:$PHP_HOME/bin
而後重啓 profile
source /etc/profile
[root@localhost bin]# source /etc/profile [root@localhost bin]# [root@localhost bin]# [root@localhost bin]# php -v PHP 7.1.7 (cli) (built: Jan 23 2018 19:32:07) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
終於大功告成,坑太深!