zoukankan      html  css  js  c++  java
  • linux下php-5.4.8.tar.gz编译安装全攻略

    首先安装基础依赖组建,注:这些依赖组建也是LINUX+PHP+MYSQL+APACHE+NGINX+MEMCACHED时必要的系统组件 
    LANG=C 

    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel gd* bzip2 bzip2-devel ncurses ncurses-devel net-snmp-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libmcrypt libmcrypt-devel

    下载 php-5.4.8.tar.gz (相应临近版本即可)

    #wget  http://cn2.php.net/get/php-5.4.8.tar.gz/from/this/mirror

    #tar zxvf  php-5.4.8.tar.gz

    #cd php-5.4.8

    ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-freetype-dir --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-session --with-gettext

    (./configure 中提示缺少什么依赖组建,yum install 相应组建即可)

    编译过程中可能存在类似这样的警告信息:

    ---------------------------------------------------------------------------------------------------------
        #configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
       解决方法如下:(或者直接无视它,这并不影响php的正常安装运行)

       wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
        tar -zxvf re2c-0.13.5.tar.gz
        cd re2c-0.13.5
        ./configure && make && make install

    service apache restart 重启APACHE时出现如下错误
    httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load
    /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

    解决方案,执行如下语句 即可

    [root@server2 ~]# chcon -t textrel_shlib_t '/usr/local/apache2/modules/libphp5.so'

    [root@server2 ~]# service apache restart
    [root@server2 ~]# echo $?
    0


    make(这里可能由于mysql  libmysqlclient.so.18加载失败 二出现点小差错,注意,这仅仅是可能,处理方法如下)

    make install(如果提示如下信息,则说明一切顺利,安装成功!)

    Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
    You may want to add: /usr/local/php/lib/php to your php.ini include_path
    /var/ftp808/php-5.4.8/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
    ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
    Installing PDO headers:          /usr/local/php/include/php/ext/pdo/


    复制源码包里的php.ini-production配置文件到PHP安装目录即(cp /var/ftp808/php-5.4.8/php.ini-production /usr/local/php/lib/php.ini)

    注意php新版本此文件名有变更 具体根据版本 实际文件名路径

    #cp php.ini-production  /usr/local/php/lib/php.ini

    ------------------------------

    修改apache的配置文件httpd.conf

    增加

    AddType application/x-httpd-php .php

     

    修改www的默认文件地址DocumentRoot

    注意还要修改Directoty的路径和上面的一样

     

    重启httpd

     

    测试php文件

    phpinfo()

    ---------------------------------

     执行php文件

    #/usr/local/php/bin/php    xx.php


    关于灵异事件,在执行make时候提示

    类似error while loading shared libraries: libmysqlclient.so.18: cannot open 错误,

    这表明libmysqlclient.so.18 没有加载成功,执行下面语句进行手动注册 然后重新编译即可

    方法一:
    具体根据MYSQL实际安装目录 修改路径
    如我的mysql安装在/usr/local/mysql下,则结果为
    ldconfig /usr/local/mysql/lib/libmysqlclient.so.18(mysql5.6.12路径格式)
    ldconfig /usr/local/mysql/lib/mysql/libmysqlclient.so.18(老版本路径格式)

    方法二:
    locate libmysqlclient.so.16
    如我的mysql安装在/usr/local/mysql下,则结果为
    /usr/local/mysql/lib/libmysqlclient.so.18(mysql5.6.12路径)
    /usr/local/mysql/lib/mysql/libmysqlclient.so.18(mysql老版本路径)
    vi /etc/ld.so.conf
    增加一行 /usr/local/mysql/lib
    然后执行ldconfig生效。
    如果上述方法均不生效,可能你需要方法三:

    方法三:
    打开/etc/ld.so.conf
    include ld.so.conf.d/*.conf
    增加
    /usr/local/mysql(根据实际安装路径)
    /usr/local/mysql/lib(根据实际安装路径,这里是cmake编译下的新版本路径格式,5.X以上旧版本一般为/usr/local/mysql/lib/mysql/)

    然后运行ldconfig即可

    我的家庭电脑采用的方法一,服务器采用的是方法三,VPS用了方法二

  • 相关阅读:
    Balanced Binary Tree
    Minimum Depth of Binary Tree
    Path Sum
    Flatten Binary Tree to Linked List
    Distinct Subsequences
    Chp3: Stacks and Queue
    Chp2: Linked List
    Populating Next Right Pointers in Each Node
    Valid Palindrome
    Binary Tree Maximum Path Sum
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3202936.html
Copyright © 2011-2022 走看看