linux下php扩展安装方式
PHP扩展的安装方式通常分为两种:
1. 随同PHP编译
2. 生成单独的.so文件
这里介绍第二种方式,对于第二种方式执行效率可能低些,但是模块化,就是可以保持php安装不变的情况下,通过php.ini连接单独生成的so文件实现扩展,
比如您已经通过了tar包方式安装了php,那么现在想增加扩展:
安装CURL扩展
I. 生成动态链接库文件.SO
方法如下:
方法1. apt-get install php5-curl
方法2. 去PHP网站下载tar包,phpize本地编译生成.so
方法3. pear方式安装,通过pecl命令去在线下载编译生成.so
方法1在ubuntu下是最简单的,命令执行完会告知.so所在目录
II. 配置php.ini
打开php.ini,指定extension_dir目录,如果extension_dir = '/usr/lib',那么接下来把生成的.so文件(如curl.so)复制到/usr/lib目录下,并且加入一个新条目:
extension=curl.so
III. 使之生效
重新启动apache,运行phpinfo()看是否生效
安装PDO_MYSQL扩展
采用pear方式安装
I. 安装pear
apt-get install php-pear 如果没有pear要先安装pear
II. 安装pdo,pdo_mysql
pecl install pdo pecl install pdo_mysql
生成.so复制到/usr/lib目录下.
如果没有安装php和mysql的开发包,在执行第II步之前还需要安装
apt-get install php5-devapt-get install libmysqlclient15-dev
III. 修改配置文件php.ini
增加条目
extension=pdo.so
extension=pdo_mysql.so
IV. 使之生效
重新启动apache,运行phpinfo()看是否生效
在php5.2.10中,php默认已经安装了pdo,所以extension=pdo.so不加,但是发现和自己生成的pdo_mysql.so不匹配错误,解决办法是:
重新安装php,增加参数--disable-pdo 禁止pdo模块,用自己前面生成pdo.so,pdo+mysql.so就OK了
安装ImageMagic扩展
采用pear方式安装
I. 安装ImageMagick
sudo apt-get install imagemagick
II. 安装imagemagick 的lib 供php调用
sudo apt-get install libmagick++-dev
III. 调用当前的pecl安装imagick
pecl install imagick
IV. 修改php.ini.重启apache服务器
在php.ini中添加: extension = imagick.so
phpize的安装
phpize是属于php-devel的内容,所以只要运行
apt-get install php-devel就行。ubuntu 下是 apt-get install php-dev
我安装的时候装的是php5-dev
装完之后是用phpize5来装自己编写的php扩展

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
