现在的位置: 首页 > 编程开发 > Php > 编程开发 > 正文

Mac os x 下安装workerman详细教程

2015年11月18日 Php, 编程开发 ⁄ 共 2973字 ⁄ 字号 暂无评论

由于公司的项目是用的是wokerman 前面一直是在Ubuntu系统下跑workerman开发的,安装没有问题 ,最近将开发环境换成MacBook 下 发现扩展都装了 但是workerman启动不了,Mac默认是自带php环境的,我自带的php版本是php5.5.30 然后扩展安装了,却发现一只启动不了,最后在问了walkor后 让换一个php版本 换了一个php版本就可以了,具体步骤如下
首先mac 是自带了php环境 我们需要自己再安装一个php然后替换掉原有的php就可以了

1.安装homebrew

homebrew是mac下非常好用的包管理器,会自动安装相关的依赖包,将你从繁琐的软件依赖安装中解放出来。
安装homebrew也非常简单,只要在终端中输入:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

homebrew的常用命令:
brew update #更新可安装包的最新信息,建议每次安装前都运行下
brew search pkg_name #搜索相关的包信息
brew install pkg_name #安装包

2.替换homebrew镜像源

由于homebrew上面的东西 很多要么被墙,要么死慢,需要替换掉原有的brew源
这里用的清华大学的源
用终端 输入以下

cd /usr/local
git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew.git
brew update

然后可以安装 nginx mysql 之类的 这里只介绍安装php

3.安装替换原有的PHP
添加brew的PHP扩展库:

brew tap homebrew/dupes
brew tap homebrew/php
brew update
brew search php

3
选择一个要安装的php的版本这里选择的5.6
开始安装PHP5.6,安装后的php-fpm.ini以及php.ini都在目录:/usr/local/etc/php/5.6/下面
这个安装完成有有提示

安装完成后有提示

songdeMacBook-Pro:w3af song$ brew install homebrew/php/php56
==> Installing php56 from homebrew/homebrew-php
==> Downloading https://homebrew.bintray.com/bottles-php/php56-5.6.15.el_capitan.bottle
Already downloaded: /Library/Caches/Homebrew/php56-5.6.15.el_capitan.bottle.3.tar.gz
==> Pouring php56-5.6.15.el_capitan.bottle.3.tar.gz
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so

The php.ini file can be found in:
/usr/local/etc/php/5.6/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that
you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

PATH="/usr/local/bin:$PATH"

PHP56 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
~/.zshrc, ~/.profile or your shell's equivalent configuration file:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

The control script is located at /usr/local/opt/php56/sbin/php56-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php56.plist' in old versions
of this formula.

To have launchd start homebrew/php/php56 at login:
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
Then to load homebrew/php/php56 now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
==> Summary
🍺 /usr/local/Cellar/php56/5.6.15: 330 files, 50M

4
然后看到每个✩✩✩✩ ✩✩✩✩ 后面就是重点
大概就是说如果要替换掉自带的php就 执行以下操作
你执行下后面的命令 全部执行完后 然后 php -v 查看版本 php -m 看有哪些扩展
然后执可以在命令中运行 curl -Ss http://www.workerman.net/check.php | php 检测本地环境是否满足workerman。

brew安装的php默认是没有安全redis扩展 如果还有用上其他的扩展自行用brew下载对应版本扩展即可

显示支持 ok 然后下载官网提供的案例跑下

2

 

给我留言

您必须 [ 登录 ] 才能发表留言!

×