php編譯openssl模塊的步驟

jsbrml 9年前發布 | 9K 次閱讀 PHP開發

來自: http://blog.csdn.net//wgw335363240/article/details/41984267


php編譯openssl模塊的步驟

最近我們打算在php框架中使用composer來管理依賴關系,但是在執行composer的安裝命令時(如下),發現系統提示沒有安裝openssl擴展類庫。

安裝composer命令:

sudocurl -s https://getcomposer.org/installer | sudo php

異常如下:

Some settings onyour machine make Composer unable to work properly.

Make sure thatyou fix the issues listed below and run this script again:

The opensslextension is missing, which means that secure HTTPS transfers areimpossible.

If possible youshould enable it or recompile php with --with-openssl



看到這個異常,應該是我的php在編譯的過程中沒有增加-with-openssl選項造成的。但是在網上搜索相關問題時,發現我們不需要重新編譯php環境,可以借助phpize來只編譯openssl.so文件,并把該文件添加到php.ini文件中的。

1.環境

1)操作系統:

Linuxubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014x86_64 x86_64 x86_64 GNU/Linux

2)php源碼目錄:

/home/wuguowei/software/php-5.5.14_source

3)php編譯后的目錄:

/home/wuguowei/software/php5.5

2.步驟

#從源碼目錄拷貝openssl目錄到編譯后的目錄文件中

sudocp -r /home/wuguowei/software/php-5.5.14_source/ext/openssl /home/wuguowei/software/php5.5/include/php/ext

#進入php編譯后的目標文件中

cd/home/wuguowei/software/php5.5/include/php/ext

#依次執行如下代碼

/home/wuguowei/software/php5.5/bin/phpize

./configure--with-openssl–with-php-config=/home/wuguowei/software/php5.5/bin/php-config

make&& make install

#找到php.ini文件(通常在/etc/php.in)中的“DynamicExtensions”的內容,在末尾添加上“extension= openssl.so”

#重啟php服務器即可

#查看編譯后的openssl的方法

php-i |grep 'openssl'

正確的結果如下:

root@ubuntu:/home/wuguowei/software/composer#php -i |grep openssl

openssl

OLDPWD=> /home/wuguowei/software/php5.5/include/php/ext/openssl

_SERVER["OLDPWD"]=> /home/wuguowei/software/php5.5/include/php/ext/openssl



#查看php命令在哪兒的命令

whereis php

which php

 本文由用戶 jsbrml 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!