zoukankan      html  css  js  c++  java
  • 编译安装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

    配置nginx支持php

    server {
        listen 80;
        server_name php.****.net;
    
        location / {
            index  index.php;
    }
        location ~ .php$ {
            include fastcgi_params;
            root /data1/www/php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
        }
    }

    下面是利用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

     修改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

  • 相关阅读:
    Java内置包装类
    for循环思路题
    常用函数
    函数
    冒泡排序
    数组的运用
    for循环中有意思的练习题。
    for循环
    运算中容易出现的错误
    分支的运用
  • 原文地址:https://www.cnblogs.com/zphqq/p/9700097.html
Copyright © 2011-2022 走看看