导航:首页 > 编程系统 > php5217linux

php5217linux

发布时间:2023-05-05 15:18:53

Ⅰ 如何在linux下安装多个不同版本的PHP

Linux (测试环境 Ubuntu 12.04 Server X86_64)
1. 安装编译工具及所需类库
$ sudo apt-get install build-essential gcc g++ autoconf libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev bzip2 libbz2-dev openssl libssl-dev curl libcurl4-openssl-dev libpcre3 libpcre3-dev libevent-1.4-2 libevent-dev libmcrypt4 libmcrypt-dev mcrypt libltdl-dev libldap2-dev libsasl2-dev libmhash-dev libc-client2007e libc-client2007e-dev
2. 安装MySQL
$ sudo apt-get install mysql-server libmysqlclient-dev
3. 安装PHP
Linux下多版本PHP共存需要自己手工编译安装。
下载PHP源文件到/opt/src目录
$ mkdir /opt/src
$ cd /opt/src
$ wget http://museum.php.net/php5/php-5.2.17.tar.bz2 -O php-5.2.17.tar.bz2
$ wget http://cn2.php.net/get/php-5.3.28.tar.bz2/from/this/mirror -O php-5.3.28.tar.bz2
$ wget http://cn2.php.net/get/php-5.4.29.tar.bz2/from/this/mirror -O php-5.4.29.tar.bz2
$ wget http://cn2.php.net/get/php-5.5.14.tar.bz2/from/this/mirror -O php-5.5.14.tar.bz2
创建PHP各版本安装目录
$ mkdir -p /opt/php/{5217,5328,5429,5514}
安装PHP 5.2.17
$ cd /opt/src
$ tar -xvjf php-5.2.17.tar.bz2
$ cd php-5.2.17
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libkrb5.so /usr/lib/libkrb5.so
$ wget -O debian_patches_disable_SSLv2_for_openssl_1_0_0.patch “https://bugs.php.net/patch-display.php?bug_id=54736&patch=debian_patches...”
$ patch -p1 < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
$ ./configure --prefix=/opt/php/5217 --with-config-file-scan-dir=/opt/php/5217/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-mime-magic --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-recommended /opt/php/5217/lib/php.ini
安装PHP 5.3.28
$ cd /opt/src
$ tar -xvjf php-5.3.28.tar.bz2
$ cd php-5.3.28
$ ./configure --prefix=/opt/php/5328 --with-config-file-scan-dir=/opt/php/5328/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5328/lib/php.ini
安装PHP 5.4.29
$ cd /opt/src
$ tar -xvjf php-5.4.29.tar.bz2
$ cd php-5.4.29
$ ./configure --prefix=/opt/php/5429 --with-config-file-scan-dir=/opt/php/5429/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5429/lib/php.ini
安装PHP 5.5.14
$ cd /opt/src
$ tar -xvjf php-5.5.14.tar.bz2
$ cd php-5.5.14
$ ./configure --prefix=/opt/php/5514 --with-config-file-scan-dir=/opt/php/5514/etc/php.d --with-mysql --with-pdo-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-ftp --disable-debug --disable-ipv6 --disable-short-tags --enable-calendar --with-imap --with-imap-ssl --with-kerberos
$ make
$ sudo make install
$ cp php.ini-development /opt/php/5514/lib/php.ini
4. 安装Apache
$ sudo apt-get install apache2
启用相应模块
$ a2enmod headers
$ a2enmod expires
$ a2enmod actions
$ a2enmod rewrite
5. 配置Apache
$ sudo vi /etc/apache2/httpd.conf
追加如下脚本映射和虚拟主机配置,原理同Windows的配置说明。
ServerName localhost
AddType application/x-httpd-php .php
ScriptAlias /php-5217/ "/opt/php/5217/bin/"
ScriptAlias /php-5328/ "/opt/php/5328/bin/"
ScriptAlias /php-5429/ "/opt/php/5429/bin/"
ScriptAlias /php-5514/ "/opt/php/5514/bin/"
<Directory /var/www/sites>
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/sites/5217>
Action application/x-httpd-php "/php-5217/php-cgi"
</Directory>
<Directory /var/www/sites/5328>
Action application/x-httpd-php "/php-5328/php-cgi"
</Directory>
<Directory /var/www/sites/5429>
Action application/x-httpd-php "/php-5429/php-cgi"
</Directory>
<Directory /var/www/sites/5514>
Action application/x-httpd-php "/php-5514/php-cgi"
</Directory>
# Virtualhosts
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5217/test.local"
ServerName php5217.local
ErrorLog "/var/log/apache2/php5217.local-error.log"
CustomLog "/var/log/apache2/php5217.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5328/test.local"
ServerName php5328.local
ErrorLog "/var/log/apache2/php5328.local-error.log"
CustomLog "/var/log/apache2/php5328.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5429/test.local"
ServerName php5429.local
ErrorLog "/var/log/apache2/php5429.local-error.log"
CustomLog "/var/log/apache2/php5429.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/sites/5514/test.local"
ServerName php5514.local
ErrorLog "/var/log/apache2/php5514.local-error.log"
CustomLog "/var/log/apache2/php5514.local-access.log" common
</VirtualHost>
保存配置后,创建各站点的DocumentRoot目录,再往每个目录放置一个phpinfo的测试文件,完成后重启Apache服务器并在本地hosts文件加入域名解析,现在就可以访问各站点来测试多版本PHP共存了。

好了,基本的多版本PHP共存解决方案已经完成,如果还需要添加其他的PHP类库支持,后续自己再调用对应php目录下的pecl, php_config等脚本编译安装就可以了。

Ⅱ 怎么在linux运行php文件

在命令行运行的话来,linux和Windows环境下自一样,如果你的PHP已经设置为全局的,可以直接
php 后跟文件名,如果不是全局的就进入php安装bin目录下,就是有php.exe文件那个目录下执行 php+文件名

Ⅲ php7 linux上使用 call_user_func_array 报错

php __call()与call_user_func_array()理解 1. mixed __call ( string name, array arguments )The magic method __call() allows to capture invocation of non existing methods. That way __call() can be used to implement user defined method handling that depends on the name of the actual method being called. This is for instance useful for proxy implementations. The arguments that were passed in the function will be defined as an array in the $arguments parameter. The value returned from the __call() method will be returned to the caller of the method. 译文: 这个魔术方法允许用户调用类中不存在的方法,它用于实现那些 依赖于在被调用时的真正方法名的方法. 典型的例子是用来实现代理. 方法的参数$arguments是一个数组 ,__call()的返回值返回给方法调用者白话文: 这个方法主要是用来实现动态方法调用, 如果再一个类定义了__call()这个方法, 当用户调用这个类的一个不存在的方法时,他可以使用调用的那个不存在的方法的方法名和参数做出用户定义在__call()方法体内的相应操作,此时__call()方法的参数就是被调用的那个不存在的方法的方法名和参数例子<?phpclass Person{function talk( $sound ){echo $sound;}function __call( $method , $args ){echo 'you call method ' . $method . '
';echo 'and the arguments are
';var_mp( $args );}}$person = new Person();$person->test( 1 , TRUE );?>程序输出引用you call method testand the arguments are array 0 => int 1 1 => boolean true2. mixed call_user_func_array ( callback function, array param_arr )Call a user defined function with the parameters in param_arr. 参数functionThe function to be called. param_arrThe parameters to be passed to the function, as an indexed array. 返回值Returns the function result, or FALSE on error. 此方法可以通过传入类名,类中得方法名和方法参数达到动态调用方法的效果例子<?php class Person{function talk( $sound ){echo $sound;}function __call( $method , $args ){echo 'you call method ' . $method . '
';echo 'and the arguments are
';var_mp( $args );}} $person = new Person();call_user_func_array( array( $person , 'talk' ) , array( 'hello' ) );?>程序输出引用hello两个方法共用,实现代理模型 class Person{function talk( $sound ){echo $sound;}function __call( $method , $args ){echo 'you call method ' . $method . '
';echo 'and the arguments are
';var_mp( $args );}}class PersonProxy{private $person;function __construct(){$this->person = new Person();}function __call( $method , $args ){call_user_func_array( array( $this->person , $method ) , $args );}}$person_proxy = new PersonProxy(); $person_proxy->talk( 'thank you' );程序输出引用thank yo

Ⅳ PHP7安装intl扩展和linux安装icu

一 PHP intl 是国际化扩展,是ICU 库的一个包装器。所以在安装PHP intl扩展前要先安装ICU库,安装ICU库的具体步骤::

二 安装intl扩展
1:进入php7.2.5源码:

2:运行:phpize ,找不到命令时,将路径补全:/usr/local/php7/bin/phpize(是php的安装路径),出现如下:

Configuring for:
PHP Api Version: 20100412
Zend Mole Api No: 20100525

Zend Extension Api No: 220100525

3:运行配置

./configure --enable-intl --with-icu-dir=/usr/local/icu/ --with-php-config=/usr/local/php7/bin/php-config

注陵手:前面路径为icu的安装路径,后面路径为php的安装路径。

4:编译扩展:make

5:复制扩展到目标文件夹

cp /user/local/php/php7.2.5/ext/intl/moles/intl.so /user/local/php7/lib/php/extensions/no-debug-non-zts-20170718

注意中汪坦:也可卖桐以find / -name intl.so 查找。

6:设置扩展加入配置文件中:

[intl]
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/"

extension=intl.so

大坑:::采用phpinfo()时,无法找到配置的intl扩展,说明配置没有生效。。。。。。

原因:在编译php时没有 --with-config-file-path=PATH 指定php.ini路径,默认的路径为/usr/local/php7/lib,只需要将php.ini放入这个默认的路径即可。你也可以安装配置php时加入,如下:

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath -enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --enable-pcntl --with-curl --with-fpm-user=nginx --enable-ftp --enable-session --enable-xml --with-apxs2=/usr/bin/apxs
访问:index.php中phpinfo()文件。

Ⅳ 如何让PHP有权限执行Linux下的命令

最近帮一个朋友搞个东西,但是用的是比较笨的方法,代码如下--------主要是让PHP获取专更大的权限属去执行LINUX命令,有权限去重启nginx服务或者重启Apache服务。
<?php
// 作用取得客户端的ip、地理信息、浏览器、本地真实IP
//此文档编码类型:utf-8
//程序使用:
//include("XXX.php") //引入类
// $gifo = new get_gust_info();//实例化
// $gifo->GetBrowser(); //获得访客浏览器类型
// $gifo->GetLang(); //获得访客浏览器语言
// $gifo->GetOs(); //获取访客操作系统
// $gifo->Getip(); //获得访客真实ip
// $gifo->get_onlineip(); //获得本地真实IP
// $gifo->Getaddress($ip); //参数 $ip 是可选的,默认返回一个二维数组包含当前访客所在地的相关信息
//

Ⅵ Linux的PHP服务要怎么启动

linux如何启动php服务?我们一起来了解一下吧。
1、打开linux系统,在linux的桌面的空白处右击。

2、在弹出的下拉选项里,点击打开终端。
3、输入/etc/init.d/php-fpmstart命令,回车即可开启PHP服务。
以上就是小编的分享,希望能帮助到大家。

Ⅶ PHP怎么调用Linux命令终端

首先先要给大家介绍PHP执行linux系统命令的几个基本函数。

system函数

说明:执行外部程序并显示输出资料。

语法:string system(string command, int [return_var]);

返回值: 字符串

详细介绍:

本函数就像是 C 语中的函数 system(),用来执行指令,并输出结果。若是 return_var 参数存在,则执行 command 之后的状态会填入 return_var 中。同样值得注意的是若需要处理用户输入的资料,而又要防止用户耍花招破解系统,则可以使用 EscapeShellCmd()。若 PHP 以模块式的执行,本函数会在每一行输出后自动更新 Web 服务器的输出缓冲暂存区。若需要完整的返回字符串,且不想经过不必要的其它中间的输出界面,可以使用 PassThru()。

实例代码:

< ?php

$last_line = system('ls', $retval);

echo 'Last line of the output: ' . $last_line;

echo '<hr/>Return value: ' . $retval;

?>

exec函数

说明:执行外部程序。

语法:string exec(string command, string [array], int [return_var]);

返回值: 字符串

详细介绍:

本函数执行输入 command 的外部程序或外部指令。它的返回字符串只是外部程序执行后返回的最后一行;若需要完整的返回字符串,可以使用 PassThru() 这个函数。

要是参数 array 存在,command 会将 array 加到参数中执行,若不欲 array 被处理,可以在执行 exec() 之前呼叫 unset()。若是 return_var 跟 array 二个参数都存在,则执行 command 之后的状态会填入 return_var 中。

值得注意的是若需要处理使用者输入的资料,而又要防止使用者耍花招破解系统,则可以使用 EscapeShellCmd()。

实例代码:

< ?php

echo exec('whoami');

?>

popen函数

说明:打开文件。

语法:int popen(string command, string mode);

返回值: 整数

详细介绍:

本函数执行指令开档,而该文件是用管道方式处理的文件。用本函数打开的文件只能是单向的 (只能读或只能写),而且一定要用 pclose() 关闭。在文件操作上可使用 fgets()、fgetss() 与 fputs()。若是开档发生错误,返回 false 值。

实例代码:

< ?

$fp = popen( "/bin/ls", "r" );

?>

通过上述函数,PHP可以执行linux系统的shell命令。

阅读全文

与php5217linux相关的资料

热点内容
微信公众号版头设计 浏览:917
jdk18读取配置文件 浏览:72
优化关键字挖掘工具 浏览:672
markdown代码块语法 浏览:249
arcgis面文件属性 浏览:43
当数据都带有标准差如何计算 浏览:936
声音挑选程序扫描本地 浏览:57
编程语言中如何拼接两个字串符 浏览:482
工地数据中心包括哪些 浏览:972
人工成本分析工具 浏览:565
苹果qq群文件在哪里 浏览:724
产品和单位成本分析后有哪些数据 浏览:144
日语教程软件 浏览:99
有哪些事业编制的app 浏览:89
天籁app是什么来的 浏览:605
app上手机通话记录如何删除 浏览:798
win7建立超级隐藏文件夹 浏览:416
网络融合的意义 浏览:162
商务标文件内容和要点 浏览:161
远程桌面怎么修改密码 浏览:246

友情链接