一、mysql安装

mysql是安装最简单顺利的

1. 首先去官方网站下载Mac适用的MySQL的dmg包

下载页面 选择图中最下方的dmg包下载进行安装

安装完成后 MySQL的安装目录为/usr/local/mysql/

2. 启动服务

设置里 找到MySQL 启动服务 显示running 则服务已启动

上图倒数第二

上图服务已启动

如果需要在终端内执行MySQL命令 需要加入环境变量

  1. export PATH=$PATH:/usr/local/mysql/bin/

MySQL安装完成

二、redis安装

1. 到官方网站下载redis 当前版本 redis-3.2.1.tar.gz

下载地址:http://redis.io/download

  1. tar -zxvf ./redis-3.2..tar.gz  #解压压缩包
  2.  
  3. cd ./redis-3.2.1          #进入解压的软件目录内
  4.  
  5. sudo make install          #执行安装
  6.  
  7. redis-server           #启动redis

2. 安装完成之后 修改redis的配置文件及启动脚本

配置文件 注意修改启动脚本相关路径的配置:

  1. vi /Library/LaunchDaemons/com.redis.plist
  2.  
  3. #启动脚本内容
  4.  
  5. <?xml version="1.0" encoding="UTF-8"?>
  6.  
  7. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  8.  
  9. <plist version="1.0">
  10.  
  11. <dict>
  12.  
  13. <keyLabel</key>
  14.  
  15. <stringcom.redis</string>
  16.  
  17. <keyRunAtLoad</key>
  18.  
  19. <true/>
  20.  
  21. <keyProgramArguments</key>
  22.  
  23. <array>
  24.  
  25. <string/usr/local/redis/bin/redis-server</string redis
  26.  
  27. <string/usr/local/redis/redis.conf</string redis.conf
  28.  
  29. </array>
  30.  
  31. </dict>
  32.  
  33. </plist>
  34. #保存退出

  35. launchctl load /Library/LaunchDaemons/com.redis.plist #加载启动脚本
  36.  
  37. launchctl start com.redis #启动服务
  38.  
  39. ps aux | grep redis #查看进程是否启动

三、php安装

本人Mac里自带的php版本为5.5 启动正常 但是zend guard loader扩展始终安装不上最后决定使用php5.4

这里提到一个网站 http://php-osx.liip.ch/

网站里有多个PHP版本的集成包 已经内置好了各种扩展 redis memcace mysql等等安装过程极简单

官方给出了相应的命令

  1. curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4

等待命令执行完成 我这里用时大概二十分钟左右安装完成后php会安装到/usr/local/目录下php5

  1. export PATH=/usr/local/php5/bin:$PATH #加入环境变量
  2.  
  3. php -v
  4.  
  5. PHP 5.4. (cli) (built: Mar ::)
  6.  
  7. Copyright (c) - The PHP Group
  8.  
  9. Zend Engine v2.4.0, Copyright (c) - Zend Technologies
  10.  
  11. with Xdebug v2.2.5, Copyright (c) -, by Derick Rethans

显示php已经是5.4版本

虽然安装了很多扩展 但是并没有zend guard loader的扩展 因此还要下载相关的扩展进行安装

这里要说明一下PHP安装完成后的目录结构

  1. cd /usr/local/php5
  2. ls -l
  3. drwxr-xr-x root wheel : bin
  4. -rw-r--r-- root wheel : entropy-php.conf
  5. drwxr-xr-x root wheel : etc #配置文件目录php.ini php-fpm.conf 如有需要推荐修改./php.d/99-liip-developer.ini
  6. drwxr-xr-x root wheel : include
  7. drwxr-xr-x root wheel : info
  8. drwxr-xr-x root wheel : lib
  9. -rwxr-xr-x root wheel : libphp5.so
  10. drwxr-xr-x root wheel : php.d  #php各种扩展加载的配置目录 其中99-liip-developer.ini可修改配置相当于php.ini
  11. drwxr-xr-x root wheel : sbin
  12. drwxr-xr-x root wheel : share
  13. drwxr-xr-x root wheel : var

安装ZendGuardLoader

  1. tar -zxvf ./ZendGuardLoader--PHP-5.4-darwin10.-x86_64.tar.gz
  2. cp ./ZendGuardLoader--PHP-5.4-darwin10.-x86_64/php-5.4.x/ZendGuardLoader.so /usr/local/php5/lib/php/extensions/no-debug-non-zts-/

增加启动脚本(注意修改相关文件路径)

  1. vi /etc/php-fpm
  2.  
  3. #! /bin/sh
  4.  
  5. ### BEGIN INIT INFO
  6.  
  7. # Provides: php-fpm
  8.  
  9. # Required-Start: $remote_fs $network
  10.  
  11. # Required-Stop: $remote_fs $network
  12.  
  13. # Default-Start:
  14.  
  15. # Default-Stop:
  16.  
  17. # Short-Description: starts php-fpm
  18.  
  19. # Description: starts the PHP FastCGI Process Manager daemon
  20.  
  21. ### END INIT INFO
  22.  
  23. prefix=/usr/local/php5/
  24.  
  25. exec_prefix=${prefix}
  26.  
  27. php_fpm_BIN=${exec_prefix}/sbin/php-fpm
  28.  
  29. php_fpm_CONF=${prefix}/etc/php-fpm.conf
  30.  
  31. php_fpm_PID=${prefix}/var/run/php-fpm.pid
  32.  
  33. php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"
  34.  
  35. wait_for_pid () {
  36.  
  37. try=while test $try -lt ; docase "$1" in
  38.  
  39. 'created')
  40.  
  41. if [ -f "$2" ] ; then
  42.  
  43. try=''
  44.  
  45. break
  46.  
  47. fi
  48.  
  49. ;;
  50.  
  51.  
  52. 'removed')
  53.  
  54. if [ ! -f "$2" ] ; then
  55.  
  56. try=''
  57.  
  58. break
  59.  
  60. fi
  61.  
  62. ;;
  63.  
  64. esacecho -n .
  65.  
  66. try=`expr $try + `
  67.  
  68.  
  69. force-quit)
  70.  
  71. echo -n "Terminating php-fpm "
  72.  
  73.  
  74. if [ ! -r $php_fpm_PID ] ; then
  75.  
  76. echo "warning, no pid file found - php-fpm is not running ?"
  77.  
  78. exit
  79.  
  80. fikill -TERM `cat $php_fpm_PID`
  81.  
  82.  
  83. wait_for_pid removed $php_fpm_PID
  84.  
  85.  
  86. if [ -n "$try" ] ; then
  87.  
  88. echo " failed"
  89.  
  90. exit
  91.  
  92. else
  93.  
  94. echo " done"
  95.  
  96. fi
  97.  
  98. ;;
  99.  
  100. restart)
  101.  
  102. $ stop
  103.  
  104. $ start
  105.  
  106. ;;
  107.  
  108. reload)
  109.  
  110. echo -n "Reload service php-fpm "
  111.  
  112.  
  113. if [ ! -r $php_fpm_PID ] ; then
  114.  
  115. echo "warning, no pid file found - php-fpm is not running ?"
  116.  
  117. exit
  118.  
  119. fi
  120.  
  121.  
  122. kill -USR2 `cat $php_fpm_PID`
  123.  
  124.  
  125. echo " done"
  126.  
  127. ;;
  128.  
  129.  
  130. *)
  131.  
  132. echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"
  133.  
  134. exit
  135.  
  136. ;;
  137.  
  138. esac

四、nginx安装

这里推荐使用OpenResty

OpenResty ™ 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

下载OpenRestytar

  1. #安装
  2. tar -zxvf ./openresty-1.9.7.5.tar.gz
  3.  
  4. cd ./openresty-1.9.15.1
  5.  
  6. ./configure
  7.  
  8. make
  9.  
  10. make install

注意 这一步安装可能会报错 需要安装 PCRE 和 OpenSSL

Mac OS X 不像linux那样 可以使用yum安装软件 依赖包

推荐大家使用brew

首先执行下面命令进行安装

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

brew安装完成可以直接使用

关于brew的详细介绍请查看官方说明https://git.io/brew-docs

  1. brew update
  2.  
  3. brew install pcre openssl

安装完成后重新编译安装openresty

  1. ./configure --prefix=/usr/local/openresty \ #指定安装目录
  2.  
  3. --with-cc-opt="-I/usr/local/Cellar/openssl/1.0.2h_1/include/ -I/usr/local/Cellar/pcre/8.39/include/" \
  4.  
  5. --with-ld-opt="-L/usr/local/Cellar/openssl/1.0.2h_1/lib/ -L/usr/local/Cellar/pcre/8.39/lib/" \
  6.  
  7. #使用 ./configure --help 查看更多的选项。
  8.  
  9. make
  10.  
  11. make install

OpenResty安装完成后 找到nginx目录进行配置文件的修改

  1. cd /usr/local/openresty
  2.  
  3. ls -l
  4.  
  5. drwxr-xr-x root admin : bin
  6.  
  7. drwxr-xr-x root admin : luajit
  8.  
  9. drwxr-xr-x root admin : lualib
  10.  
  11. drwxr-xr-x root admin : nginx
  12.  
  13. drwxr-xr-x@ root admin : pod
  14.  
  15. -rw-r--r--@ root admin : resty.index
  16.  
  17. cd ./nginx/conf/
  18.  
  19. ls -l
  20.  
  21. -rw-r--r--@ root admin : fastcgi.conf
  22.  
  23. -rw-r--r--@ root admin : fastcgi.conf.default
  24.  
  25. -rw-r--r--@ root admin : fastcgi_params
  26.  
  27. -rw-r--r--@ root admin : fastcgi_params.default
  28.  
  29. -rw-r--r-- root admin : injection.lua
  30.  
  31. -rw-r--r--@ root admin : koi-utf
  32.  
  33. -rw-r--r--@ root admin : koi-win
  34.  
  35. -rw-r--r--@ root admin : mime.types
  36.  
  37. -rw-r--r--@ root admin : mime.types.default
  38.  
  39. -rw-r--r-- root admin : nginx.conf
  40.  
  41. -rw-r--r--@ root admin : nginx.conf.default
  42.  
  43. -rw-r--r--@ root admin : scgi_params
  44.  
  45. -rw-r--r--@ root admin : scgi_params.default
  46.  
  47. -rw-r--r--@ root admin : uwsgi_params
  48.  
  49. -rw-r--r--@ root admin : uwsgi_params.default
  50.  
  51. drwxr-xr-x root admin : vhosts
  52.  
  53. -rw-r--r--@ root admin : win-utf
  54.  
  55. #根据需要修改相关配置文件

nginx启动

  1. sudo /usr/local/openresty/nginx/sbin/nginx

本文已在版权印备案,如需转载请访问版权印89818122

Mac下安装 php+nginx+mysql 开发环境的更多相关文章

  1. Mac下安装LNMP(Nginx+PHP5.6)环境

    [转自:http://avnpc.com/pages/install-lnmp-on-osx] 安装Homebrew 最近工作环境切换到Mac,所以以OS X Yosemite(10.10.1)为例, ...

  2. Mac下安装LNMP(Nginx+PHP5.6)环境(转)

    安装Homebrew 最近工作环境切换到Mac,所以以OS X Yosemite(10.10.1)为例,记录一下从零开始安装Mac下LNMP环境的过程 确保系统已经安装xcode,然后使用一行命令安装 ...

  3. MAC 下用 brew 搭建 PHP 开发环境

    Mac下用brew搭建PHP(LNMP/LAMP)开发环境 Mac下搭建lamp开发环境很容易,有xampp和mamp现成的集成环境.但是集成环境对于经常需要自定义一些配置的开发者来说会非常麻烦,而且 ...

  4. 第一篇:Win10系统搭建Python+Django+Nginx+MySQL 开发环境详解(完美版)

    Win10+Python+Django+Nginx+MySQL 开发环境搭建详解 PaulTsao 说明:本文由作者原创,仅供内部参考学习与交流,转载引用请注明出处,用于商业目的请联系作者本人. Wi ...

  5. Mac下搭建Cocos2d-x-3.2的开发环境

    配置:OS X 10.9.4 + Xcode 6.0 + Cocos2d-x-3.2 摘要:本文目标为在Xcode成功运行HelloWorld程序. 一.下载必要项 1.从官网下载Cocos2d-x- ...

  6. mac 下 用 glfw3 搭建opengl开发环境

    mac 下 用 glfw3 搭建opengl开发环境 下载编译 glfw3 Build Setting 里面, Library Search Paths -> 设置好编译 glfw 库的路径 H ...

  7. MAC下安装与配置MySQL

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

  8. Mac下使用brew搭建PHP7+nginx+mysql开发环境

    http://blog.csdn.net/mysteryhaohao/article/details/52230634 HomeBrew brew的安装,直接上官网:http://brew.sh/ 一 ...

  9. Mac配置PHP+Nginx+MySQL开发环境

    Homebrew简称brew,OSX上的软件包管理工具,在Mac终端可以通过brew安装.更新.卸载各种软件,(简直就是神器级武器). 废话不多说,没安装brew自己去百度学习安装,这里就不多说了. ...

随机推荐

  1. IE11新特性 -- Internet Explorer 11:请不要再叫我IE

    Internet Explorer 11 中的一些新特性,包括对WebGL 的支持.预抓取.预渲染.flexbox.mutationobservers 以及其他一些 Web 标准的支持.但是更有趣的是 ...

  2. codevs 3223 素数密度

    题目描述 Description 给定区间[L, R](L <= R <= 2147483647,R-L <= 1000000),请计算区间中素数的个数. 输入描述 Input De ...

  3. 离线破win2003域账号密码(更新域数据库不在默认路径的情况)

    国内网站讲了许多方法,很多也讲得不清楚.我把我尝试成功的经验跟大家分享. 方法是按照tim的文章操作,链接如下: http://pauldotcom.com/2011/11/safely-dumpin ...

  4. ECMA 6 记入

    好书推荐 : http://es6.ruanyifeng.com/ String.prototype -includes, startsWith, endsWith -padStart, padEnd ...

  5. Big Data Security Part One: Introducing PacketPig

    Series Introduction Packetloop CTO Michael Baker (@cloudjunky) made a big splash when he presented ‘ ...

  6. 分布式文件系统 FastDFS Ceph

    分布式文件系统 FastDFS Cephhttp://www.oschina.net/p/fastdfshttp://www.oschina.net/p/ceph FastDFS 的 Go 客户端 f ...

  7. iOS 9之WatchKit for WatchOS 2

    金田(github示例源码) 自AppleWatch发行的同时就可以为AppWatch开发相应的应用程序,不过最初的版本,能开发的功能极为有限,所以也只是有少数的App厂商为Apple定制了App,所 ...

  8. HDU_1042——阶乘,万进制

    #include <cstdio> ; const int BASE = MAX; int main() { int n, i, j; while(~scanf("%d" ...

  9. linux下常用FTP命令

    linux下常用FTP命令 1. 连接ftp服务器 1. 连接ftp服务器格式:ftp [hostname| ip-address]a)在linux命令行下输入: ftp 192.168.1.1b)服 ...

  10. iOS 捕获系统外异常

    iOS 捕获系统外异常 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太 ...