一,安装homebrew

就像linux下面有yum一样,mac也有个homebrew,管理软件非常便捷。

官网:http://brew.sh/index_zh-cn.html

上面有句命令,复制下来终端执行,如果命令返回404没找到,命令以官网最新为参考。

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

任意键继续,可能需要输入你MAC的开机密码

漫长的等待。。。可以去洗个澡了再回来看

brew help可以看帮助

二,安装nginx

brew install nginx

#重新加载配置|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit
#测试配置是否有语法错误
nginx -t

又是漫长的等待

nginx -v 查看版本

打开 nginx 后,默认的访问端口 8080,如果要改为常用的 80 端口,则要修改 "/usr/local/etc/nginx/nginx.conf" 下监听(listen)端口值。

默认的文件访问目录(root)是 "/usr/local/Cellar/nginx/1.8.0/html"(这里的1..8.0是安装的nginx的版本,文件夹名以安装的nginx版本为准)。

把 nginx 设置为开机启动运行:

mkdir -p ~/Library/LaunchAgents

cp /usr/local/Cellar/nginx/1.8./homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/

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

不过试了一下,不是超级用户登陆,而是普通用户登陆,并且监听的端口在1024以下的(例如把默认的8080端口改为了80端口),nginx 开机是启动不了。因此,要 nginx 开机启动的话,需要给予它管理员权限:

sudo chown  root:wheel /usr/local/Cellar/nginx/1.8.0/bin/nginx

sudo chmod  u+s /usr/local/Cellar/nginx/1.8.0/bin/nginx

二,安装mysql

brew install mysql 

安装完之后登陆,报了个错,MySQL server through socket '/tmp/mysql.sock

启动一下mysql,在试一下

mysql.server restart

如果觉得很麻烦。直接到官网下个mac的dmg版mysql吧

记得卸载 brew remove mysql ,

下载mysql官网的mac dmg版安装即可,安装完之后,在偏好设置里面会出现mysql的图标,和java,flash一样,打开看下,下面的勾选开机启动

cd ; nano .bash_profil
打开编辑这个文件
export PATH="/usr/local/mysql/bin:$PATH"

control+x 后回车退出
source ~/.bash_profile

mysql登陆,如果遇到
-bash: mysql: command not found

原因:这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。
首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,我们则可以这样执行命令:

# ln -s /usr/local/mysql/bin/mysql /usr/bin

设置你的密码
/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere' mysql -uroot -pyourpasswordhere 登陆成功!

三、安装php-fpm

Mac是预装了php,不过很多扩展都没安装,目测最多只能在终端里执行下php指令,所以我选择重新安装php。由于 brew 默认是没有 php 安装,所以要使用 “brew tap” 来安装 brew 的第三方程序包,这里使用 josegonzalez 的php安装包,具体操作如下:

1
2
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

执行完后,就可以用 brew 安装php了。这里php有几个版本可以安装,具体可以执行 "brew search php" 查看一下有什么php版本可以安装,一般会有“php52、php53、php54”版本,我安装的是最新的php5.6版本。(php7.0尝试多次编译不过去放弃了。)

由于PHP5.4以上版本已经内嵌了 FPM,FastCGI Process Manager),在安装选项里标明就行,本人 php 的安装配置指令如下:

brew install php56 --with-debug --with-homebrew-curl --with-imap --with-homebrew-libressl --with-homebrew-libxslt  --with-libmysql --without-apache --with-fpm

安装完后会出一段提示的。

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" //这个放在环境变量文件~/bash_profile的/usr/sbin/的前面,优先选择brew的php 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" //命令行执行后才能php -v查看最新的php安装的版本 ✩✩✩✩ 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 //执行后 开机启动php-fpm 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" //更新安装,有则忽略,没有则加到~/.bash_profile 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 josegonzalez/php/php56 at login:
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents //使用php
Then to load josegonzalez/php/php56 now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist //使用php
==> Summary

mac下安装nginx+php+mysql+xdebug的更多相关文章

  1. MAC下安装与配置MySQL

    MAC下安装与配置MySQL   MAC下安装与配置MySQL 一 下载MySQL 访问MySQL的官网http://www.mysql.com/downloads/ 然后在页面中会看到“MySQL ...

  2. Linux 环境下安装 Nginx+php+mysql 开发环境

    一直以来都没有养成记录学习的好习惯,我想从这么一天开始,把自己学习和工作中的经验和坑都记录下来.等到以后老的时候还有可以回忆的地方. 最近在学习linux,虽然已经玩linux很久了,但是没有怎么用心 ...

  3. Mac 下 安装 Nginx

    ---恢复内容开始--- Mac 下 安装nginx 首先确定自己有安装homebrew 安装 nginx brew install nginx 启动nginx 1.15版本下 安装是 直接在ngin ...

  4. 《OD大数据实战》mac下安装nginx+php

    一.mac安装nginx + php + php-fpm  或apache + php 1. Mac 下 Nginx.MySQL.PHP-FPM 的安装配置 2. Mac下安装LNMP(Nginx+P ...

  5. Windows下安装Nginx+php+mysql环境

    系统:Windows 7 64位系统 安装之前,首先下载软件: Nginx: http://nginx.org/en/download.html PHP Stable PHP 5.6.26: http ...

  6. mac下安装nginx问题解决

    需要在mac上安装nginx,按照下面的博客链接一步步安装,但是碰到了些问题.下面写一下我的解决方式. (http://stevendu.iteye.com/blog/1535466) 1. 安装PC ...

  7. mac 下安装nginx

    1,mac下的依赖: pcre-8.38.tar.gz nginx-1.4.7.tar.gz 2,解压pcre:进入器解压目录. EddydeMacBook-Pro:~ eddy$ cd /Users ...

  8. windows与mac下安装nginx

    window下 下载链接,自己选一个版本下载 nginx官网下载 本人放在D盘: 启动nginx 有很多种方法启动nginx (1)直接双击nginx.exe,双击后一个黑色的弹窗一闪而过 (2)打开 ...

  9. mac下安装nginx及相关配置

    1. 安装 Homebrew   首先 homebrew是什么?它是Mac中的一款软件包管理工具,通过brew可以很方便的在Mac中安装软件或者是卸载软件.不了解的同学看以看官网(https://br ...

随机推荐

  1. sync

    tools-android-Sync Project ---------------- file-Project Structure add dependencies

  2. workbench中safe update

    1.在workbench中表格显示为readonly ,更新时提示Error Code: 1175. You are using safe update mode and you tried to u ...

  3. javascript中正则表达式的基础语法

    × 目录 [1]定义 [2]特点 [3]元字符[4]转义字符[5]字符组[6]量词[7]括号[8]选择[9]断言[10]模式[11]优先级[12]局限性 前面的话 正则表达式在人们的印象中可能是一堆无 ...

  4. Centos搭建Python+Nginx+Tornado+Mysql环境[转载]

    Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入 ...

  5. Dashborad 上显示出错

    Dashboard 上显示的错误是因为没有选择对应的X-坐标. 上周处理过 一个字段,它是一个Formula 字段,作为Dashboard的 Data Source 前提是报表是得Group by 一 ...

  6. ISO学习中代码截图

    自定义插件 1.使用时的调用方法 导入头文件,创建对象,设置尺寸,传入数据: 2,内部方法的实现 XMGPageView.m XMGPageView.h XMGPageView.xib 注意点 自定义 ...

  7. Python—RabbitMQ

    RabbitMQ RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统 安装 因为RabbitMQ由erlang实现,先安装erlang #安装配置epel源 rpm -ivh http ...

  8. 【转】创建SVN仓库的步骤

    转载地址:http://www.cnblogs.com/ivan0626/p/3783053.html   今天在客户现场联调,两个开发人员之间的代码想用SVN来管理,所以就临时在本地机器上搭建一个S ...

  9. org.hibernate.AssertionFailure:collection[......] was not processed by flush()

    八月 12, 2016 11:00:49 上午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() f ...

  10. Nudnik Photographer -Ural1260动态规划

    Time limit: 1.0 second Memory limit: 64 MB If two people were born one after another with one second ...