前面介绍过基本的配置,后来我又从网上查找了很多资料,经过不断的摸索,下面做了一个总结,希望能对大家提供些许帮助(Mac版本是sierra)
一.mac系统会自带git,而我们要做的是自己安装git
使用命令
git --version 可以查看系统自带的git版本
which git 可以查看git的所在地址
brew install git 来安装git
brew info git 可以查看brew中的git信息
现在我们要明确下自带git和我们安装的git所在的地址
自带的git安装在 /usr/local/bin/git
brew 安装的地址是 /usr/local/Cellar/git/2.10.2 类似的
我们进入到 /usr/local/bin目录下
list git* 会列出含有git的文件名字
创建一个文件夹 back,然后将自带git移入到文件中
mv git* ./back/
接下来配置路径(更改 bash_profile)
sudo vim ~/.bash_profile
加入以下内容
export GIT=/usr/local/Cellar/git/2.1.3
export PATH=$GIT/bin:$PATH
然后刷新环境变量
source ~/.bash_profile
此时就大功告成了
二.安装php7.0
1>使用 brew doctor 可以检查你的brew运行情况
2>添加brew的PHP扩展库:(mac os 比较歧视PHP,不包含PHP的包,那么我们就要绑定其他人的git仓库,用法是$ brew tap <gihhub_user/repo>)
brew update
brew tap homebrew/dupes
brew tap homebrew/php
(有些地方使用brew tap josegonzalez/homebrew-php或者brew tap josegonzalez/php,我去josegonzalez的仓库看了下都是fork的homebrew的仓库,所以我认为有上面两个仓库够用了,就不写osegonzalez的了)
可以使用brew options php70命令来查看安装php的选项,请注意:如果你希望以mac下的apache作为web server,编译时要加 --with-apache;如果你的web server 是 nginx这类,就需要加上 --with-fpm。这里我用下面的选项安装
brew install php70 --with-apxs2 --with-apache --with-gmp --with-imap --with-tidy --with-debug
下面提个坑,--with-apache这个要带上,否则macos sierra系统在安装php7的时候不会产生相应的libphp7.so模块
然后将下载的apache卸载,方法是
brew list //查看都安装了哪些
brew uninstall //卸载相应的模块
brew cleanup -s //清除缓存和老旧版本文件
brew link php70 //开启PHP70进程
php -v //测试是否成功
当你安装完之后,输入
brew info php70
打出来的信息我放在了文章末尾,这些话很重要,请仔细阅读
3>修改apache配置文件
打开配置文件
sudo vim /etc/apache2/httpd.conf
先将下面两句注释掉
#LoadModule php5_module libexec/apache2/libphp5.so
#Include /private/etc/apache2/other/*.conf 这行
然后增加下面三项
LoadModule php7_module /usr/local/Cellar/php70/7.0.0rc.4/libexec/apache2/libphp7.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
4>由于Mac自带了php,因此需要添加系统环境变量PATH来替代自带PHP版本(如果你使用ngix,那马你还有考虑关于fpm的配置)
进入配置文件
sudo vim ~/.bash_profile
将以下内容加入到路径中,注意/usr/local/bin在/usr/local/sbin之前
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
然后更新系统资源使之生效
source ~/.bash_profile
注意:如果你用的是zsh,那么你加入的配置文件是 ~/.zshrc
5>测试apache是否支持php70
输入 php -v 查看你当前的php版本
在apache默认目录(/Library/WebServer/Documents)下新建info.php,内容如下
<?php
phpinfo();
?>
重启apache服务
apache sudo apachectl restart
在浏览器输入localhost/info.php 当画面出现的一刻,简直是热泪盈眶
三.安装mysql
1>安装mysql
brew install mysql
2>查看mysql安装信息
brew info mysql
我们可以看到下面的一段话
#######brew info 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 now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
#######brew info mysql命令后的提示#######
那么我们就按照提示操作,输入以下命令
mysql_secure_installation
接下来就是按照提示操作,设置密码
然后决定是否要开机运行mysql,如果需要的话就运行
brew services start mysql
不需要的话就在使用的时候运行
mysql.server start
3>连接mysql
没有密码
mysql -uroot
如果你有密码
mysql -uroot -p
运行一个命令试试
show databes;
结果出来如下,
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
进入mysql命令之后退出的方法
exit
4>图形工具使用的是navicat(破解版)
四.安装redis
1>使用brew安装redis
brew install redis
2>查看安装信息
brew info redis
可以看到以下信息
##########brew info redis显示信息#########
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /usr/local/etc/redis.conf
##########brew info redis显示信息#########
如果你想要开机自启动那么
brew services start redis
如果你想使用的时候再启动
redis-server /usr/local/etc/redis.conf
3>启动redis,出现以下画面证明安装成功了
4>在终端打开新的窗口使用客户端功能
command+n组合按键打开一个新的窗口
使用redis-cli命令启动redis客户端
redis-cli
使用举例
如果想终止redis
redis-cli shutdown
备注:我使用的是laravel框架,不用自己去考虑php7的redis扩展问题
附录
########brew info php70 命令后的信息###########
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini file can be found in:
/usr/local/etc/php/7.0/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"
PHP70 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/php70)/bin:$PATH"
GMP has moved to its own formula, please install it by running: brew install php70-gmp
✩✩✩✩ FPM ✩✩✩✩
To launch php-fpm on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
The control script is located at /usr/local/opt/php70/sbin/php70-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.php70.plist' in old versions
of this formula.
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system
you have to install php with the --with-apache option. See brew options php70 for more details.
To have launchd start josegonzalez/php/php70 now and restart at login:
brew services start josegonzalez/php/php70
########brew info php70 命令后的信息###########
- mac攻略(4) -- 使用brew配置php7开发环境(mac+php+apache+mysql+redis)
[http://www.cnblogs.com/redirect/p/6131751.html] 网上有很多文章都是错误的,因为是copy别人的,作者没有自己亲测,不仅不能给新手提供帮助,还会产生严重 ...
- Mac OS安装Go语言及配置VSCode开发环境:一个工具(gopls)解千愁
前言 截止到目前为止,Go语言已经更新到1.14.1,网上的很多教程均已经过时,我在此汇总并整理一下相关的教程,提供一个适合当下的Mac OS教程. 教程中使用了Go在1.11之后推出的依赖包管理工具 ...
- 第五章 MyEclipse配置hadoop开发环境
1.首先要下载相应的hadoop版本的插件,我这里就给2个例子: hadoop-1.2.1插件:http://download.csdn.net/download/hanyongan300/62381 ...
- IIS 7完全攻略之日志记录配置(摘自网络)
IIS 7完全攻略之日志记录配置 作者:泉之源 [IT168 专稿]除了 Windows 提供的日志记录功能外,IIS 7.0 还可以提供其他日志记录功能.例如,可以选择日志文件格式并指定要记录的请求 ...
- MAC 下用 brew 搭建 PHP 开发环境
Mac下用brew搭建PHP(LNMP/LAMP)开发环境 Mac下搭建lamp开发环境很容易,有xampp和mamp现成的集成环境.但是集成环境对于经常需要自定义一些配置的开发者来说会非常麻烦,而且 ...
- Windows服务器安装配置PHP7.0环境图文教程
摘自http://www.111cn.net/phper/linux-php/109865.htm Windows服务器安装配置PHP7.0环境图文教程 www.111cn.net 更新:2016-0 ...
- Windows2016的 IIS中配置PHP7运行环境
Windows2016的 IIS中配置PHP7运行环境 在Windows 的IIS(8.0)中搭建PHP运行环境: 一:安装IIS服务器 .进入控制面板>>程序和功能>>打开或 ...
- Mac配置Java开发环境
笔者从Window上转到Mac上做开发,一切配置都要重新开始,开发环境配置介绍如下: 1. 下载JDK 从下面链接选择合适版本的安装包进行下载...笔者下载的是jdk-9.0.1 链接:http:// ...
- Mac上通过docker配置PHP开发环境
这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHPzhuanlan.zhihu. ...
随机推荐
- linux笔记七---------管道
smarty的变量调节器就是linux的管道 管道:前者的输出是后者的输入 {$name|upper} 通过调节器使得名字变为大写输出 {$name|lower} linux的管道: ls –al ...
- 理解insert all/insert first的使用
在常用的SQL写法中我们会经常遇到把一个表的数据插入另外一张表的情况,这是一个insert into 表名 select .... from 表名 就可以解决了.但是如果是把一张表的数据同时插入两 ...
- 示例Oracle 10.2.0.1.0升级到10.2.0.4.0一例
1.查看当前系统版本 [oracle@std Disk1]$ sqlplus '/as sysdba' SQL*Plus: Release - Production on Thu Jan :: Cop ...
- 2016HUAS暑假集训训练2 K - Hero
题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/K 这也是一道贪心题,刚开始写时以为只要对每一敌人的攻击和血的乘积进行从小到大排序即 ...
- E-Dijkstal
1005 输出用%f,1009别做了 Problem E Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Ja ...
- [置顶] TortoiseGit和msysGit安装及使用笔记(windows下使用上传数据到GitHub)
eclipse .MyEclipse 配置安装 git:http://wenku.baidu.com/link?url=gMT4a7K6EJWAztuwun73oPHiKqlydEdn5F3S2Win ...
- UML聚合与组合
http://www.cnblogs.com/shanwenbin/archive/2012/10/24/2737229.html UML聚合与组合 2012-10-24 15:35 by DayDa ...
- Python开发【第二章】:Python模块和运算符
一.模块初识: Python有大量的模块,从而使得开发Python程序非常简洁.类库有包括三中: Python内部提供的模块 业内开源的模块 程序员自己开发的模块 1.Python内部提供一个 sys ...
- Linux下查看系统版本号信息的方法(转)
一.查看Linux内核版本命令: 1.cat /proc/version [root@localhost ~]# cat /proc/versionLinux version 2.6.18-194.8 ...
- python file模块 替换输入内容脚本
root@python-10:/home/liujianzuo/python/test# ls passwd rc.local test1 root@python-10:/home/liujianzu ...