编译安装php5 解决编译安装的php加载不了gd

 

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、编译

下载php ,也可自行去官网下载

链接:https://pan.baidu.com/s/1yC6v6dhubJYwjjS5EUvmxw
提取码:wcbw

./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

转载于:https://www.cnblogs.com/abkn/p/9700097.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值