PHP如何添加拓GD库及安装器依赖

PHPz
Release: 2018-10-08 16:58:31
forward
1033 people have browsed it

如果我们已经装好了PHP想添加相应的拓展库怎么办。因为PHP默认是不开启GD库的,如果装好了就只能在源码中编译出库文件在添加到PHP的外部库里面。

1.进入相应外部库文件位置

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">/web/program/php-5.6.9/ext/gd<br></span>
Copy after login

提示:在源码包的ext目录下会有很多外部库文件的源码,不知道是不是全部都在那里面。

2.安装GD库相应的依赖

1.安装vpx

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">yum install -y libvpx libvpx-devel<br></span>
Copy after login

2.安装jpeg 

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">yum install -y libjpeg-turbo libjpeg-turbo-devel<br></span>
Copy after login

3.安装png 

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;"> yum install libpng libpng-devel<br></span>
Copy after login

4.安装fretype

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">yum install freetype freetype-devel</span><span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;"><br></span>
Copy after login

提示:我用的是阿里云的源,这些软件都可以找到,如果不行的话请自行切换

3.配置编译GD库

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">phpize && ./configure --with-php-config=/web/server/php/bin/php-config --with-vpx-dir=/usr/local/ --with-jpeg-dir=/usr/local/  --with-png-dir=/usr/local/ --with-freetype-dir=/usr/local && make<br></span>
Copy after login

提示:先要运行phpize,他在PHP安装目录下的bin目录 如果我没有 为PHP设系统变量的话应该是 /web/server/php/bin/phpize 

  --with-php-config后面是跟是php-config文件的目录  那些依赖默认都会安装到/usr/local中。

4.将库文件添加到PHP外部库中

复制文件到PHP安装的外部库目录 

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">cp ./modules/gd.so /web/server/php/lib/php/extensions/</span><span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;"><br></span>
Copy after login

修改php.ini 

在extension=php_xsl.dll 后面添加

extension_dir=/web/server/php/lib/php/extensions/
extension=gd.so

5.重启Apache

<span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">service apache restart</span><br><span style="font-family: 微软雅黑,Microsoft YaHei; font-size: 14px;">欧耶,GD库安装完成</span>
Copy after login

更多相关教程请访问 php编程从入门到精通全套视频教程

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template