zoukankan      html  css  js  c++  java
  • linux下编译安装php7(兼容现有的php5.6版本)

    1.首先去php官网下载一个php7版本源码包 http://php.net/downloads.php,我这下载的是php7.2.13版本. 

    2.使用ftp或者linux的rz命令将包上传到linux下,开始进行编译安装.

    3.解压安装包

    # tar -zxvf   php-7.2.13.tar.gz

    # cd php-7.2.13

    #./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mcrypt=/usr/include --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache

    执行以上编译会出现报错

    1.configure: error: jpeglib.h not found.

    解决:yum -y install libjpeg-devel .

    2.configure: error: png.h not found.

    解决:#yum install libpng 

     # yum install libpng-devel

    3.configure: error: freetype-config not found.

    解决:# yum install freetype-devel

    然后再次执行上面命令会出现:

    +--------------------------------------------------------------------+

    | License:                                                           |

    | This software is subject to the PHP License, available in this     |

    | distribution in the file LICENSE.  By continuing this installation |

    | process, you are bound by the terms of this license agreement.     |

    | If you do not agree with the terms of this license, you must abort |

    | the installation process at this point.                            |

    +--------------------------------------------------------------------+

    Thank you for using PHP.

    表示配置文件检测成功,下面开始执行编译且安装

    # make && make install  

    至此php7.2.13就安装完成 .

    安装完成在/usr/local下会出现php7目录

    # cd /usr/local/php7/etc下

    首先复制出一份php-fpm.conf

    #cp php-fpm.conf.default php-fpm.conf

    切换到/usr/local/php7/etc/php-fpm.d复制配置文件

    #cp www.conf.default www.conf

    为了兼容php5.6所以需要配置php7的监听端口为9001 (我的php5.6监听端口为9000)

    # vim  /usr/local/php7/etc/php-fpm.d/www.conf  找到:

    listen = 127.0.0.1:9000

    将其端口修改为 

    listen = 127.0.0.1:9001

    :wq 保存编辑退出. 

    然后配置nginx或apache支持php7即可.

    -----------------  Nginx 支持php7配置文件如下 ----------------------

    server {
    listen 8888;  配置项目访问端口 (如果无其他项目也可使用默认的80端口)

    location / {
    root /data/laravel/public;  #项目路径
    index index.html index.htm index.php;

    # 项目配置重写
    if (!-e $request_filename) {
    rewrite ./index.php last;
    }
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    location ~ .php$ {
    root /data/laravel/public;   #项目路径 
    fastcgi_pass 127.0.0.1:9001;  #监听端口为9001  
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;

        }

    }

    1.重启nginx

    # /usr/local/nginx/sbin/nginx -s reload

    2.重启php7

    # /usr/local/php7/sbin/php-fpm

    完成以上步骤后:

    ---->访问:http://你的域名:8888 出现配置项目显示页面或者可使用phpinfo()测试信息页则表示配置nginx+php7成功。

    至此可以开启你的php7之旅。

    以上仅为个人安装参考,如有问题可留言交流。

  • 相关阅读:
    sublime text 4 vim 插件配置
    ssh-keygen 的使用
    distribution transaction solution
    bilibili 大数据 视频下载 you-get
    Deepin 20.2.1 安装 MS SQL 2019 容器版本
    【转】使用Linux下Docker部署MSSQL并加载主机目录下的数据库
    【转】You Can Now Use OneDrive in Linux Natively Thanks to Insync
    dotnet 诊断工具安装命令
    Linux 使用 xrandr 设置屏幕分辨率
    【转】CentOS 7.9 2009 ISO 官方原版镜像下载
  • 原文地址:https://www.cnblogs.com/victorcode/p/10143536.html
Copyright © 2011-2022 走看看