Rumah > Artikel > pembangunan bahagian belakang > php版本切换的详细过程和线上Linux环境下常见php-fpm常见问题
本篇文章介绍的是php版本切换的详细过程和线上Linux环境下常见php,在这里分享给大家,也给有需要的朋友做一下参考,大家一起来看一看吧
一、php版本切换
(1)检测是否切换成功
判断是否切换成功的2个绝对正确的方法(推荐第一种):
1、ps -ef|grep php
2、写个php文件 (); ?>
(2)已有的版本切换
现有php7.0和php7.1,目前在php7.0
==========法1,亲测有效,start===================
brew services stop php70
ps -ef |grep php
brew services restart php@7.1
ps -ef |grep php
==========法1,end==========================
==========法2,start=========================
brew unlink php70
brew link php71
source ~/.bash_profile
php -v 此时显示的版本就是php7.1的了
解决: 按照提示操作即可
brew link php71 —force
echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
==========法2,start=========================
(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/
Atas ialah kandungan terperinci php版本切换的详细过程和线上Linux环境下常见php-fpm常见问题. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!