php編譯openssl模組的步驟

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.