zoukankan      html  css  js  c++  java
  • centos7 编译安装php7

    下载php7.0

    wget http://cn2.php.net/get/php-7.0.13.tar.gz/from/this/mirror
    tar -zxvf mirror
    cd php-7.0.13
    

    安装依赖

    首先安装libmcrypt依赖库

    wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
    tar -zxvf download
    cd libmcrypt-2.5.8
    ./configure
    make && make install

    安装依赖,如果要配合apacht httpd 需要添加 --with-apxs2同时安装httpd-devel。

    yum -y install libjpeg
    libjpeg-devel 
    libpng
    libpng-devel 
    freetype 
    freetype-devel 
    libxml2 
    libxml2-devel 
    pcre-devel 
    curl-devel 
    libxslt-devel 
    libjpeg.x86_64 
    libpng.x86_64 
    freetype.x86_64 
    libjpeg-devel.x86_64 
    libpng-devel.x86_64 
    freetype-devel.x86_64  
    libjpeg-devel 
    gcc-c++ 
    autoconf 
    libjpeg 
    libjpeg-devel 
    libpng 
    libpng-devel 
    freetype 
    freetype-devel 
    libpng 
    libpng-devel 
    libxml2 
    libxml2-devel 
    zlib zlib-devel 
    glibc 
    glibc-devel 
    glib2 
    glib2-devel 
    bzip2 
    bzip2-devel 
    ncurses 
    curl 
    openssl-devel 
    gdbm-devel 
    db4-devel 
    libXpm-devel 
    libX11-devel 
    gd-devel 
    gmp-devel 
    readline-devel 
    libxslt-devel 
    expat-devel 
    xmlrpc-c 
    xmlrpc-c-devel 
    libicu-devel 
    libmcrypt-devel 
    libicu-devel 
    

      

    安装

    ./configure --prefix=/usr/local/php 
    --with-apxs2 
    --with-mysql-sock --with-mysqli 
    --enable-fpm  --enable-soap 
    --with-libxml-dir --with-openssl 
    --with-mcrypt --with-mhash 
    --with-pcre-regex  --with-zlib 
    --enable-bcmath --with-iconv 
    --with-bz2 --enable-calendar 
    --with-curl --with-cdb --enable-dom 
    --enable-exif --enable-fileinfo 
    --enable-filter --with-pcre-dir 
    --enable-ftp --with-gd 
    --with-openssl-dir --with-jpeg-dir 
    --with-png-dir --with-zlib-dir 
    --with-freetype-dir 
    --enable-gd-native-ttf 
    --enable-gd-jis-conv --with-gettext 
    --with-gmp --with-mhash 
    --enable-json --enable-mbstring 
    --enable-mbregex 
    --enable-mbregex-backtrack 
    --with-libmbfl --with-onig 
    --enable-pdo --with-pdo-mysql 
    --with-zlib-dir  --with-readline 
    --enable-session --enable-shmop 
    --enable-simplexml --enable-sockets 
    --enable-sysvmsg --enable-sysvsem 
    --enable-sysvshm --enable-wddx 
    --with-libxml-dir  --with-xsl 
    --enable-zip 
    --enable-mysqlnd-compression-support 
    --with-pear --enable-intl

    编译安装

    make
    make install
    

    建立软连接

    ln -s /usr/local/php/bin/php /usr/bin
    ln -s /usr/local/php/include/php /usr/include/
    mkdir /usr/lib64/php
    ln -s /usr/local/php/lib/php/build/ /usr/lib64/php/build
    

      

    如果需要配置nginx,那么配置php-fpm

    cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
    cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
    cp php-7.0.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm

    启动php-fpm

    service php-fpm start
    

    如果是apache服务器,添加php模块和文件类型支持

    AddType application/x-httpd-php .php .html .htm
    PHPIniDir /etc
    LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so

    安装nginx

    wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
    

     配置nginx

    vim /etc/nginx/nginx.d/default.conf
    

    配置如下:

    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  /var/log/nginx/log/host.access.log  main;
    
        location / {
            root   /www;
            index  index.php index.html index.htm;
        }
    
        #error_page  404              /404.html;
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
            root           /www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
    

      

  • 相关阅读:
    HTML页面跳转的5种方法
    ngixn配置
    redis秒杀
    php 设计模式
    MySQL之事务的四大特性
    [置顶] JNI之java传递数据给c语言
    jQuery 快速结束当前动画
    编绎OpenJDK
    CF#231DIV2:A Good Number
    CF#213DIV2:B The Fibonacci Segment
  • 原文地址:https://www.cnblogs.com/yangxunwu1992/p/6271124.html
Copyright © 2011-2022 走看看