php7

centos7下yum安装PHP 7.4, 7.3 & 7.2 & 7.1

星期二, 三月 9th, 2021 | linux, php | 没有评论

centos7下yum安装PHP 7.4, 7.3 & 7.2 & 7.1

1.系统为centos7.9

2.使用yum安装 命令如下:

  sudo yum install epel-release
 
  sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

2.1:安装php版本

  ## Install PHP 7.4 
  yum --enablerepo=remi-php74 install php
 
  ## Install PHP 7.3 
  yum --enablerepo=remi-php73 install php
 
  ## Install PHP 7.2 
  yum --enablerepo=remi-php72 install php
 
  ## Install PHP 7.1 
  yum --enablerepo=remi-php71 install php

2.2 安装php相关常用扩展(Modules)

	### For PHP 7.4
yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
 
### For PHP 7.3
yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
 
### For PHP 7.2
yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
 
### For PHP 7.1
yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

2.3 支持mysql及php-fpm

  ## For PHP 7.4 
  yum --enablerepo=remi-php74 install php-fpm mysqlnd
 
  ## For PHP 7.3 
  yum --enablerepo=remi-php73 install php-fpm mysqlnd
 
  ## For PHP 7.2 
  yum --enablerepo=remi-php72 install php-fpm mysqlnd
 
  ## For PHP 7.1 
  yum --enablerepo=remi-php71 install php-fpm mysqlnd

2.4 查看更多可安装的模块

› Continue reading

Tags: , ,

让PHP7兼容老版本的php5.5.x或者5.6下的mysql_connect的处理代码

星期一, 九月 9th, 2019 | linux, php | 没有评论

1.昨天折腾了下服务器,把系统从centos6.5更新到7.6,也把对应的php版本升级到了php7.0.x系列

2.好多年没有再怎么写php代码了,以前写的也是在php5.5.x的版本写的,升级后发现程序无法使用,郁闷ing

3.跟踪下 /var/opt/remi/php70/log/php-fpm 下的 www-error.log发现是 php7已经不支持mysql_connect

4.网上找了下兼容的代码新增了 mysql_num_rows的函数的处理,我以前的老代码又可以欢快的跑起来了,记录下,也方便需要的朋友

$dbhost = DATA_HOST;
$dbport = 3306;
$dbuser = DATA_USERNAME;
$dbpass = DATA_PASSWORD;
$dbname = DATA_NAME;
if(!function_exists('mysql_connect')){
    function mysql_connect($dbhost, $dbuser, $dbpass){
        global $dbport;
        global $dbname;
        global $mysqli;
        $mysqli = mysqli_connect("$dbhost:$dbport", $dbuser, $dbpass, $dbname);
        return $mysqli;
        }
    function mysql_select_db($dbname){
        global $mysqli;
        return mysqli_select_db($mysqli,$dbname);
        }
    function mysql_fetch_array($result){
        return mysqli_fetch_array($result);
        }
    function mysql_fetch_assoc($result){
        return mysqli_fetch_assoc($result);
        }
    function mysql_fetch_row($result){
        return mysqli_fetch_row($result);
        }
    function mysql_query($query){
        global $mysqli;
        return mysqli_query($mysqli,$query);
        }
    function mysql_escape_string($data){
        global $mysqli;
        return mysqli_real_escape_string($mysqli, $data);
        }
    function mysql_real_escape_string($data){
        return mysql_real_escape_string($data);
        }
    function mysql_close(){
        global $mysqli;
        return mysqli_close($mysqli);
        }
    function mysql_num_rows($result){
        return mysqli_num_rows($result);
    }
}

Tags: , ,

windows下配置nginx1.9.x+php7开发环境

星期四, 二月 4th, 2016 | php | 没有评论

还是跑不掉在windows下配置对应的开发环境,准备:

1.下载对应的软件
nginx-1.9.10/Windows-1.9.10

PHP 7.0 (7.0.3)/php-7.0.3-nts-Win32-VC14-x86.zip

2.安装配置nginx和php

分别解压到 D:/web/nginx-1.9.10/ 和D:/web/php7/
修改php.ini-recommended文件为php.ini

打开 一堆扩展尽量打开这里示例2个

1
2
3
 extension_dir = "D:/web/php7/ext"
 extension=php_mysqli.dll
 cgi.fix_pathinfo=1  ##这个启用cgi核心关键

nginx.cnf 打开php支持 同时修改fastcgi_param 参数由/scripts$fastcgi_script_name; 修改为$document_root$fastcgi_script_name;

1
2
3
4
5
6
7
8
9
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
      root           D:/web/www;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
}

3.编辑php的脚本 (phpinfo.php)

<?php
    phpinfo();
?>

4.启动和关闭的脚本文件
启动脚本文件 start_nginx.bat

1
2
3
4
5
6
7
8
9
10
@echo off
echo starting nginx...
D:
cd D:/web/nginx-1.9.10/
start nginx
echo starting PHP FastCGI...
D:
cd D:/web/php7/
php-cgi.exe -b 127.0.0.1:9000 -c D:/web/php7/php.ini
exit

关闭脚本文件 stop_nginx.bat

1
2
3
4
5
6
@echo off
echo Stopping nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

搞定配置

Tags: ,

Search

文章分类

Links

Meta