• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

[Ubuntu] How to add PHP extension after installed PHP?

php 搞代码 4年前 (2022-01-23) 25次浏览 已收录 0个评论

Let say you installed PHP and run it for a month, but now you want to use curl in PHP.

But so bad that you didn’t install this extension when you installed PHP. That is to say,

now you want to add PHP extension.

Here is an example to install curl extension.

apache2 is in /usr/local/apache2

php is in /usr/lib/php5/

1. Install the CURL

Download the curl source code from: http://curl.haxx.se/download, here is curl-7.17.1.tar.gz.

Then uncompress and install it.

tar -zxf curl-7.17.1.tar.gz
./configure –prefix=/usr/local/curl
sudo make
sudo make test
sudo make install

Here we install the curl to /usr/local/curl

2. Install the php5-curl

*Note: You should have the php source code, otherwise the steps can’t not go on. Assume that the PHP source code

is in ~/Downloads/php-5.2.10-src, and you should have installed the phpize.

cd ~/Downloads/php-5.2.10-src/ext/curl/
phpize
./configure –with-php-config=php-config –with-curl=/usr/local/curl
sudo make
sudo make test
sudo make install

Then you will find curl.so in ~/Downloads/php-5.2.10-src/ext/curl/modules. Copy it to the php extension folder, here is /usr/lib/php5/20060613+lfs/

sudo cp ~/Downloads/php-5.2.10-src/ext/curl/modules/curl.so /usr/lib/php5/20060613+lfs/curl.so

3. Modify the php.ini file

add the code to php.ini

exten、本文来源gao($daima.com搞@代@#码$网搞gaodaima代码sion=curl.so

4. restart the apache

sudo /etc/init.d/apache2 restart

Then the curl extension is installed.


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:[Ubuntu] How to add PHP extension after installed PHP?

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址