php版本切换的详细过程+线上Linux环境下常见php-fpm常见问题

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wuhuagu_wuhuaguo/article/details/79800096

一、php版本切换

1)检测是否切换成功 

判断是否切换成功的2个绝对正确的方法(推荐第一种):

1ps -ef|grep php

2、写个php文件 <?php echo phpinfo(); ?> 


2)已有的版本切换

切换php版本2步走

注意:php72和php70,对应的fpm是php-fpm和php-fpm70,对应fpm的配置文件www.conf文件里的端口是9001和9002,

~/.bash_profile

~./bash_aliases


==先切php,有两种方法(推荐第1种):

<1>brew services stop php72,然后ps –ef|grep php如果还有,直接kill -9 进程号杀死
     brew services stop php70,ps –ef|grep php看该版本的进程是否起来了
<2>php-fpm.stop, php unlink php70,source ~/.bash_profile
     php-fpm70.start, php link php72, source ~/.bash_profile
==再切虚拟主机

cd /usr/local/etc/nginx/conf.d/, vi php-fpm,将端口改为9002
重启nginx:  sudo nginx –s reload

其中过程如下:


Mac 自带的php-fpm占用的是9000端口,
用brew安装的php7.2php-fpm是9001端口(/usr/local/etc/php/7.2/php-fpm.d/www.conf),
那么现在安装的php7.0可以改成的9002端口(/usr/local/etc/php/7.0/php-fpm.d/www.conf)
并且!!!
cd /usr/local/etc/nginx/servers/ , vi xf.conf


找到php-fpm的配置文件地址:/usr/local/etc/nginx/conf.d/php-fpm
cd /usr/local/etc/nginx/conf.d/ , vi php-fpm


重启nginx: sudo nginx –s reload(或者brew services restartnginx),就OK啦

废话一句link的本质:


此图显示link指的是php70的软连接
即: php -> ../Cellar/php/7.2.4/bin/php


3)安装新的php版本,比如5.6,并切换到该版本 

ps -ef|grep php    //当前是一堆php@7.1的进程,需要杀死掉

brew services stop php@7.1

ps -ef|grep php   //在查看,已经杀完了

brew install php56或者brew install php@5.6  //若报错,表示没此版本,不报错就已经在安装了

brew services restart php@5.6   //启用当前版本



4)两个重要文件

~/.bash_profile       ==配置文件

~/.bash_aliases      ==快捷键文件


~/.bash_aliases的文件的内容

alias nginx.start='launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist'

alias nginx.stop='launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist'

alias nginx.restart='nginx.stop && nginx.start'

alias php-fpm70.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist"

alias php-fpm70.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist"

alias php-fpm70.restart='php-fpm70.stop && php-fpm70.start'

alias php-fpm71.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist"

alias php-fpm71.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist"

alias php-fpm71.restart='php-fpm71.stop && php-fpm71.start'

alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"

alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"

alias mysql.restart='mysql.stop && mysql.start'

分析:

快捷键

实际命令

nginx.start

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist


二、线上Linux环境下常见php-fpm常见问题


解决:http://www.mamicode.com/info-detail-1157161.html 


解决:1、Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?

关闭php-fpm服务时发现报错,缺乏pid文件,解决方法为编辑配置文件,启用pid文件:

vim /usr/local/php/etc/php-fpm.conf

pid = run/php-fpm.pid

2、ERROR : failed to open error_log……..

vim /usr/local/php/etc/php-fpm.conf

error_log = /usr/local/php/log/php-fpm.log

然后 cd /usr/local/php/ ,然后创建log文件夹,赋777权限,然后再到log文件夹里创建php-fpm.log文件



http://d-prototype.com/archives/6230

造成该问题的原因是:

路径【/usr/local/php-7.0.9/etc/php-fpm.d/】下没有找到【*.conf】的配置文件(config file)。

解决:cp www.conf.default www.conf



vim /usr/local/php/etc/php-fpm.d/www.conf


解决:打开php-fpm的配置文件

/usr/local/php/etc/php-fpm.d/www.conf

找到这2条并取消注释:

listen.allowed_clients = 127.0.0.1

listen = 127.0.0.1:9000

该解决方案将使您能够在您的虚拟主机块中使用listen = 127.0.0.1:9000

然后重启: service php-fpm restart 


三、参考:

mac下安装多版本PHP及切换

https://blog.csdn.net/a_new_steven/article/details/78652585 


Linux下安装多版本PHP及切换

https://www.cnblogs.com/Julian-Chen/articles/7987003.html

https://www.cnblogs.com/oliverCJ/p/7831526.html 

http://blog.csdn.net/21aspnet/article/details/47658127/ 

展开阅读全文

没有更多推荐了,返回首页