mac php安装mysql扩展_Mac电脑安装php、mysql环境

引入Homebrew的扩展库

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/homebrew-php

1

2

3

4

brewtaphomebrew/dupes

brewtaphomebrew/versions

brewtaphomebrew/homebrew-php

通过Homebrew安装mysql

brew install homebrew/versions/mysql56

1

2

brewinstallhomebrew/versions/mysql56

Homebrew仓库的最新版本mysql是5.7,而5.6版本的mysql被转移到了扩展包homebrew/versions。

安装成功后,会有一段类似下文的提示,按照提示就能正确进行启动服务等操作:

To have launchd start homebrew/versions/mysql56 now and restart at login:

brew services start homebrew/versions/mysql56

Or, if you don't want/need a background service you can just run:

/usr/local/opt/mysql56/bin/mysql.server start

1

2

3

4

5

Tohavelaunchdstarthomebrew/versions/mysql56nowandrestartatlogin:

brewservicesstarthomebrew/versions/mysql56

Or,ifyoudon'twant/needabackgroundserviceyoucanjustrun:

/usr/local/opt/mysql56/bin/mysql.serverstart

通过Homebrew安装php7

brew search php7

brew install homebrew/php/php71

1

2

3

brewsearchphp7

brewinstallhomebrew/php/php71

安装成功后,执行php -v会有如下提示:

PHP 7.1.0beta1 (cli) (built: Jul 29 2016 07:50:40) ( NTS )

Copyright (c) 1997-2016 The PHP Group

Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies

1

2

3

4

PHP7.1.0beta1(cli)(built:Jul29201607:50:40)(NTS)

Copyright(c)1997-2016ThePHPGroup

ZendEnginev3.1.0-dev,Copyright(c)1998-2016ZendTechnologies

此时,php-fpm也已经被安装到系统中了,路径通常如下:

/usr/local/Cellar/php71/7.1.0-beta.1_2/sbin/php-fpm

/usr/local/Cellar/php71/7.1.0-beta.1_2/sbin/php71-fpm

/usr/local/sbin/php-fpm

1

2

3

4

/usr/local/Cellar/php71/7.1.0-beta.1_2/sbin/php-fpm

/usr/local/Cellar/php71/7.1.0-beta.1_2/sbin/php71-fpm

/usr/local/sbin/php-fpm

如果以前有安装过其他版本的php-fpm,可能会在如下目录:

/usr/sbin/php-fpm

1

2

/usr/sbin/php-fpm

通过/usr/local/sbin/php-fpm -t命令,可以检测配置信息是否正确,通常会返回如下的结果:

[10-Aug-2016 11:19:35] NOTICE: configuration file /usr/local/etc/php/7.1/php-fpm.conf test is successful

1

2

[10-Aug-201611:19:35]NOTICE:configurationfile/usr/local/etc/php/7.1/php-fpm.conftestissuccessful

/usr/local/sbin/php71-fpm start ### 启动php71-fpm

/usr/local/sbin/php71-fpm stop ### 关闭php71-fpm

1

2

3

/usr/local/sbin/php71-fpmstart###启动php71-fpm

/usr/local/sbin/php71-fpmstop###关闭php71-fpm

通过Homebrew安装nginx

brew install nginx

1

2

brewinstallnginx

安装成功后,nginx的配置文件存放在/usr/local/etc/nginx,该目录下,有nginx.conf配置文件,以及servers目录下的子配置文件。

nginx的默认根目录是/usr/local/var/www

nginx -t可以检查配置的正确性。

添加php-fpm的相关配置信息

server {

listen 80;

server_name php.wenlie.com;

location / {

root html/php71;

index index.html index.htm;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

location ~ \.php$ {

root html/php71;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

server{

listen80;

server_namephp.wenlie.com;

location/{

roothtml/php71;

indexindex.htmlindex.htm;

}

error_page500502503504/50x.html;

location=/50x.html{

roothtml;

}

location~\.php${

roothtml/php71;

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;

includefastcgi_params;

}

}

通过Homebrew安装 composer

brew install composer

1

2

brewinstallcomposer

composer中的fxp/composer-asset-plugin只支持composer的v1.0.0版本,而brew安装的是composer的最新版本v1.2.0,因此放弃了brew安装的方式,而采用手动安装。

wget https://getcomposer.org/download/1.0.0/composer.phar

mv composer.phar /usr/local/bin/composer

chmod a+x /usr/local/bin/composer

1

2

3

4

wgethttps://getcomposer.org/download/1.0.0/composer.phar

mvcomposer.phar/usr/local/bin/composer

chmoda+x/usr/local/bin/composer

~/.composer目录下会有一些配置信息。如果以前安装过其他版本composer的,可以先清空了,再安装。

composer global require "fxp/composer-asset-plugin:~1.1.1"

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

1

2

3

composerglobalrequire"fxp/composer-asset-plugin:~1.1.1"

composercreate-project--prefer-distyiisoft/yii2-app-basicbasic

composer config -l -g ## 能列出所有

composer config secure-http false -g ## 设置secure-http属性为false

### 因为安装yii的时候,由于目标地址是http的,而导致下载失败

1

2

3

4

composerconfig-l-g##能列出所有

composerconfigsecure-httpfalse-g##设置secure-http属性为false

###因为安装yii的时候,由于目标地址是http的,而导致下载失败

composer config命令设置的结果会保存在 ~/.composer/config.json 中。

安装完成后,使用php yii serve就可以启动一个web服务了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值