linux php多版本 查版本号,linux php多版本

陈永鹏的博客园地址:http://www.cnblogs.com/Yoperchen/

闲来没事安装个php7玩。

0.下载php7.

1.解压.

tar xzvf php-7.tar.gz

2.进入解压后的目录

cd php-7.0.1

3.

./configure --prefix=/usr/local/php7 \

--with-curl \

--with-freetype-dir \

--with-gd \

--with-gettext \

--with-iconv-dir \

--with-kerberos \

--with-libdir=lib64 \

--with-libxml-dir \

--with-MySQL \

--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-libxml \

--enable-inline-optimization \

--enable-gd-native-ttf \

--enable-mbregex \

--enable-mbstring \

--enable-pcntl \

--enable-shmop \

--enable-soap \

--enable-sockets \

--enable-sysvsem \

--enable-xml \

--enable-zip

4.make &&  make install

第4步要花比较久的时间

5.

cp -R ./sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.conf

6.

cp php.ini-development /usr/local/php7/lib/php.ini

7.

cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm7

8创建软连接,这样以后php-v 显示的是原来的PHP,php7 -v显示的是php7的相关信息

ln -s /usr/local/php7/bin/php /usr/bin/php7

9.修改端口

php默认端口是9000,原来的php5.4就用了9000端口,所以修改php7监听端口为9007

大概在这个位置

复制.conf文件

cp /usr/local/php7/etc/php-fpm.d/www.conf.default www.conf

vim www.conf 修改如下,我的在第36行。

320cdf781d74652c2e956df8ac9dcd69.png

没有复制成.conf的话会报错,如下

WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125.

ERROR: No pool defined. at least one pool section must be specified in config file

ERROR: failed to post process the configuration

ERROR: FPM initialization failed

9.启动:

/etc/init.d/php-fpm7

看看是否有启动

ps -aux|grep php

我的

2b28d6a09044dc133f64253a3149bad5.png

nginx 配置.

原先我已经有了一个php5.3版本,现在多了一个php7。所以要分别配置

一个server指向php5.3,一个server指向php7.0

如下,使用project2.test.com访问的是project2项目,调用的是php7

#默认使用原来的php运行

server {

listen 80;

server_name *.test.com;

location / {

root /usr/nginx/html/my_project;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /usr/nginx/html/my_project;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

#project2使用php7运行

server {

listen 80;

server_name project2.test.com;

location / {

root /usr/nginx/html/project2;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /usr/nginx/html/project2;

fastcgi_pass 127.0.0.1:9007;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

如图

89870dee8ef9dff41444464c55342451.png

如有问题,可以在下面留言~

新建php文件,phpinfo();

89870dee8ef9dff41444464c55342451.png

命令解释

configure --prefix=/

指定安装路径

不指定prefix,则可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr /local/share。你要卸载这个程序,要么在原来的make目录下用一次make uninstall(前提是make文件指定过uninstall),要么去上述目录里面把相关的文件一个个手工删掉。

指定prefix,直接删掉一个文件夹就够了

--prefix指的是安装路径,--with指的是安装本文件所依赖的库文件。

本文作者:陈永鹏

邮箱:chen.yong.peng@foxmail.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值