1、 编译安装php需要的模块:

yum install libxml2-devel libxml2  curl curl-devel  libpng-devel  libpng  openssl openssl-devel -y

yum install php-mcrypt libmcrypt libmcrypt-devel  freetype*  libjpeg-devel

2、编译

./configure   --prefix=/usr/local/php   --with-config-file-path=/usr/local/php/etc  --enable-libxml   --enable-xml   --enable-bcmath   --enable-shmop   --enable-sysvsem   --enable-inline-optimization   --enable-opcache   --enable-mbregex   --enable-fpm   --enable-mbstring=all   --enable-gd-native-ttf   --with-openssl   --enable-pcntl   --enable-sockets   --with-xmlrpc   --enable-zip   --enable-soap   --without-pear   --with-gettext   --enable-session   --with-curl   --enable-ctype   --enable-shared   --with-gd --with-jpeg-dir=/usr/local/jpeg  --with-freetype-dir=/usr/include/freetype2/freety   --with-mysql=mysqlnd --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd  --with-mcrypt

3、安装make && make install

4、配置文件cp php.ini-production /usr/local/php/etc/php.ini

cd  /usr/local/php/etc && cp php-fpm.conf.default php-fpm.conf

5、配置php-fpm启动脚本

[root@iZbp1f922lx535jt6fpxm5Z sbin]# vim /lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config=/usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -SIGINT $PIDFILE

[Install]
WantedBy=multi-user.target

配置环境变量  /etc/profile最后加上如下这句

export PATH=$PATH:/usr/local/php/bin

至此已编译ok

下面是利用phpize安装php扩展gd模块

1、进入gd目录执行phpize命令后,当前目录会生成一个新的configure文件,如果没有可能是没有autoconf,yum -y install autoconf安装一下

然后执行./configure --with-php-config=/usr/local/php/bin/php-config

然后make && make install

执行结束后,会出现下面画面,表示安装成功

2、配置php.ini

去掉extension=php_gd2.dll 前面的分号取消注释

修改php.ini中 extension_dir =  “ext”  为绝对路径 extension_dir =  “”/usr/local/src/php-5.5.38/ext/“”

在php.ini最后加上下面这句

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20121212/gd.so

3、重启nginx  php-fpm

systemctl restart php-fpm

systemctl restart nginx

4、验证安装是否成功

其他gd库

JPEG  https://blog.csdn.net/zzzxxbird/article/details/53609783

freetype

先yum install freetype*

再找到freetype位置,find / -name freetype

最后重新编译php

./configure   --prefix=/usr/local/php   --with-config-file-path=/usr/local/php/etc  --enable-libxml   --enable-xml   --enable-bcmath   --enable-shmop   --enable-sysvsem   --enable-inline-optimization   --enable-opcache   --enable-mbregex   --enable-fpm   --enable-mbstring=all   --enable-gd-native-ttf   --with-openssl   --enable-pcntl   --enable-sockets   --with-xmlrpc   --enable-zip   --enable-soap   --without-pear   --with-gettext   --enable-session   --with-curl   --enable-ctype   --enable-shared   --with-gd --with-jpeg-dir=/usr/local/jpeg  --with-freetype-dir=/usr/include/freetype2/freety   --with-mysql=mysqlnd --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd  --with-mcrypt

zlib   https://blog.csdn.net/azh89125/article/details/78464784

redis  https://www.cnblogs.com/doseoer/p/6161110.html

解决yum 安装没有libphp5.so

1、安装

yum install httpd
yum install httpd-devel

2、找到apsx 所在路径

3、加上apsx后重新编译php

./configure   --prefix=/usr/local/php   --with-config-file-path=/usr/local/php/etc  --enable-libxml   --enable-xml   --enable-bcmath   --enable-shmop   --enable-sysvsem   --enable-inline-optimization   --enable-opcache   --enable-mbregex   --enable-fpm   --enable-mbstring=all   --enable-gd-native-ttf   --with-openssl   --enable-pcntl   --enable-sockets   --with-xmlrpc   --enable-zip   --enable-soap   --without-pear   --with-gettext   --enable-session   --with-curl   --enable-ctype   --enable-shared   --with-gd --with-jpeg-dir=/usr/local/jpeg  --with-freetype-dir=/usr/include/freetype2/freety   --with-mysql=mysqlnd --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd  --with-mcrypt   --with-apxs2=/usr/bin/apxs

make && make install

4. 修改apache配置文件,Centos7.4 下的apache2.4的配置文件路径为

vim /etc/httpd/conf/httpd.conf

//在LoadModule后面添加:LoadModule php5_module modules/libphp5.so //不添加则访问.php文件将会变成下载
//在DirectoryIndex后面添加:index.php
//在AddType application/x-gzip .gz .tgz后面添加:AddType application/x-httpd-php .php //.php前面有一个空格

5、重启httpd

编译安装php5 解决编译安装的php加载不了gd的更多相关文章

  1. Laravel4快速安装方法,解决Laravel4安装速度慢

    Laravel4原始安装方法 Laravel4 是构建在 Composer 之上的, 之前的安装方法是如下:   composer create-project laravel/laravel you ...

  2. 解决win7 下 curl无法加载的问题

    最近分别在WIN7和Windows8 上分别安装php 高版本!都遇到了这个问题! 一.win7系统64位, apache2.2, php 5.35 vc6 版本 这个比较容易: 1. phpinfo ...

  3. 解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题

    下面两种现象,用同一种方法解决 1.解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题 2.突然有一天首页访问图片很慢,至少隔20多秒所有图片才会出来.(解析:app使 ...

  4. 解决hibernate中的懒加载(延迟加载)问题

    解决hibernate中的懒加载(延迟加载)问题   我们在开发的时候经常会遇到延迟加载问题,在实体映射时,多对一和多对多中,多的一样的属性默认是lazy="true"(即,默认是 ...

  5. 解决ArcGIS API for Silverlight 加载地图的内外网访问问题

    原文:解决ArcGIS API for Silverlight 加载地图的内外网访问问题 先上一个类,如下: public class BaseClass { public static string ...

  6. 解决tableView中cell动态加载控件的重用问题

    解决tableView中cell动态加载控件的重用问题 tableView的cell,有时候需要在运行时取得对应的数据后才能够动态的创建该cell中的控件并加载到该cell中,此时,你一定会遇到重用问 ...

  7. Kali之——解决物理机U盘安装Kali Linux2018.1,光驱无法加载问题

    Kali系统和烧录软件 链接:https://pan.baidu.com/s/1v78d62hdF95NM2minct9sw 提取码:b08k 1.无效的方法: (1)执行 df -m,然后查看U盘设 ...

  8. homebrew安装和解决brew安装速度慢的问题

    homebrew安装 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/inst ...

  9. 解决物理机U盘安装Kali Linux2018.1,光驱无法加载问题

    1.无效的方法: (1)执行 df -m,然后查看U盘设备是否挂载到了/media,导致cd-rom不能被挂载,执行 umount  /media. (2)在光驱加载安装界面,把U盘拔下换到电脑的另外 ...

随机推荐

  1. [UE4]Cast to OverlaySlot、Set Vertical Alignment、Get Slot,解决Child Widget垂直居中对齐问题

  2. golang 反射应用(二)

    golang反射应用(二) package test import ( "reflect" "testing" ) //定义适配器 func TestRefle ...

  3. (转)Linux netstat命令详解

    简介 Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Member ...

  4. win10间歇性的找不到usb设备

    自从安装了win10,感觉掉了一个好大的坑. 比如win10经常找不到usb 设备,有时候过5-6分钟又有了.除了驱动的问题之外,有时候重启一下就好了. 今天又有一个小发现,笔记本为了省电,会把usb ...

  5. centos7安装zookeeper3.4.12集群

    zookeeper的三要素: 1.一致,能够保证数据的一致性 2.有头,始终有一个leader,node/2+1个节点有效,就能正常工作 3.数据树,树状结构且每个树必须有数据 1. 环境准备 操作系 ...

  6. C# DataGirdview手动添加数据,导出txt文件并自动对齐

    //DataGirdview手动添加数据 private void btnDataGirdView_Click(object sender,EventArgs e) {       dataGridV ...

  7. centos6.2 安装Mysql5.6

    1. mysql官网下载rpm包 [root@slave2 home]# ls hbase  hive  mysql  mysql57-community-release-el6-11.noarch. ...

  8. jquery选择器筛选器

    jQuery对象 Query 对象就是通过jQuery包装DOM对象后产生的对象.jQuery 对象是 jQuery 独有的. 如果一个对象是 jQuery 对象, 那么它就可以使用 jQuery 里 ...

  9. 什么是Apache Flink

    大数据计算引擎的发展 这几年大数据的飞速发展,出现了很多热门的开源社区,其中著名的有 Hadoop.Storm,以及后来的 Spark,他们都有着各自专注的应用场景.Spark 掀开了内存计算的先河, ...

  10. WebView长按保存图片;WebView不跳转到系统的浏览器;WebView加载显示进度条;WebView返回事件处理;

    直接看代码即可,代码里面注释写的很清楚,这个类拉下来就能用: 写法和命名比较粗暴,但也简单易懂: public class MainActivity extends AppCompatActivity ...