码迷,mamicode.com
首页 > Web开发 > 详细

php5,7安装

时间:2018-05-25 23:29:15      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:php安装

安装PHP5
  • PHP官网www.php.net
  • 当前主流版本为5.6/7.1
  • cd /usr/local/src/
  • wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
  • tar zxf php-6.6.30.tar.gz
  • cd php-5.6.30
  • ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

    apxs2这个工具可以自动加载apache的扩展模块,指定mysql的驱动,后面的参数是指定php所需要的模块

    configure: error: xml2-config not found. Please check your libxml2 installation.
    [root@aminglinux-02 php-5.6.30]# yum install -y libxml2-devel
    configure: error: Cannot find OpenSSL‘s <evp.h>
    [root@aminglinux-02 php-5.6.30]# yum install -y openssl-devel
    configure: error: Please reinstall the BZip2 distribution
    [root@aminglinux-02 php-5.6.30]# yum install -y bzip2-devel
    configure: error: jpeglib.h not found.
    [root@aminglinux-02 php-5.6.30]# yum install -y libjpeg-devel
    configure: error: png.h not found.
    [root@aminglinux-02 php-5.6.30]# yum install -y libpng-devel
    configure: error: freetype-config not found.
    [root@aminglinux-02 php-5.6.30]# yum install -y freetype-devel
    configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    [root@aminglinux-02 php-5.6.30]# yum install -y libmcrypt-devel
  • make && make install
  • cp php.ini-production /usr/local/php/etc/php.ini//复制配置文件
    [root@akuilinux01 php-5.6.30]# ls /usr/local/php/
    bin  etc  include  lib  php
    [root@akuilinux01 php-5.6.30]# du -sh /usr/local/php/bin/php
    36M /usr/local/php/bin/php  //主文件
    [root@akuilinux01 php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 
    37M /usr/local/apache2.4/modules/libphp5.so  //php主模块
    [root@akuilinux01 php-5.6.30]# /usr/local/php/bin/php -m //加载的模块,静态的
    [PHP Modules]
    bz2
    Core
    ctype
    date
    dom
    ereg
    exif
    fileinfo
    filter
    gd
    hash
    iconv
    json
    libxml
    mbstring
    mcrypt
    mysql
    mysqli
    openssl
    pcre
    PDO
    pdo_mysql
    pdo_sqlite
    Phar
    posix
    Reflection
    session
    SimpleXML
    soap
    sockets
    SPL
    sqlite3
    standard
    tokenizer
    xml
    xmlreader
    xmlwriter
    zlib
    [Zend Modules]
  • php是作为apache的扩展模块存在的
  • 查看php的安装信息
    [root@akuilinux01 php-5.6.30]# /usr/local/php/bin/php -i |less

    安装PHP7

  • cd /usr/local/src/
  • wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
  • tar jxf php-7.1.6.tar.bz2
  • cd php-7.1.6
  • ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  • make && make install
  • ls /usr/local/apache2.4/modules/libphp7.so
  • cp php.ini-production /usr/local/php7/etc/php.ini //复制配置文件
  • php5和7可以同时安装,但是apache调用的时候只能调用一个,在/usr/local/apache2.4/conf/httpd.conf里面修改,不用的直接注释
    [root@akuilinux01 ~]# vim /usr/local/apache2.4/conf/httpd.conf
    #LoadModule rewrite_module modules/mod_rewrite.so
    LoadModule php5_module        modules/libphp5.so
    #LoadModule php7_module        modules/libphp7.so

扩展

php5,7安装

标签:php安装

原文地址:http://blog.51cto.com/akui2521/2120442

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!