|首先加入Homebrew官方的几个软件源
$ brew tap homebrew/dupes $ brew tap homebrew/versions $ brew tap homebrew/php
|安装PHP5.6
$ brew install php56
新问题:安装完成后没有Apache用的php5.so
- 卸载: $ brew remove php56 - 安装: $ brew install php56 —with-apache 如果出现以下内容说明被弃用了 Warning: homebrew/php/php56: --with-apache was deprecated; using --with-httpd24 instead! 需要执行该命令来安装: $ brew install php56 --with-httpd24
|安装Apache
$ brew install httpd24 或 $ brew install homebrew/apache/httpd24 配置文件路径为/usr/local/etc/apache2/2.4/httpd.conf Apache 支持PHP 1、加载模块libphp5.so:一般在 /usr/local/Cellar/php56/5.6.19/libexec/apache2/libphp5.so 2、后缀名 <IfModule php5_module> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps <IfModule dir_module> DirectoryIndex index.htm index.html index.php </IfModule> </IfModule>
|安装mysql
$ brew install mysql We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation To connect run: mysql -uroot To have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents Then to load mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist Or, if you don't want/need launchctl, you can just run: mysql.server start
添加修改mysql配置
mysqld --help --verbose | more (查看帮助, 按空格下翻) 你会看到开始的这一行(表示配置文件默认读取顺序) Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 注意:通常这些位置是没有配置文件的, 所以要自己建一个 ls $(brew --prefix mysql)/support-files/my-* (用这个可以找到样例.cnf) cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf (拷贝到第一个默认读取目录) 建议拷贝到 /usr/local/etc/my.cnf (以免mac系统升级可能会丢失) 按需修改my.cnf,然后重启 mysql