Set root password? [Y/n] Y Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
➜ ~ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.16 Homebrew
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
Warning! If you have existing PHP installations via Brew, you need to first cleanup your setup with our Upgrading Homebrew guide before continuing with this section.
Up until the end of March 2018, all PHP related brews were handled by Homebrew/php tab, but that has been deprecated, so now we use what’s available in the Homebrew/core package. This should be a better maintained, but is a much less complete, set of packages.
Both PHP 5.6 and PHP 7.0 has been deprecated and removed from Brew because they are out of support, and while it’s not recommended for production, there are legitimate reasons to test these unsupported versions in a development environment.
Remember only PHP 7.1 through 7.3 are officially supported by Brew so if you want to install PHP 5.6 or PHP 7.0 you will need to add this tap:
1
$ brew tap exolnet/homebrew-deprecated
We will proceed by installing various verions of PHP and using a simple script to switch between them as we need. Feel free to exclude any versions you don’t want to install.
The first one will take a little bit of time as it has to install a bunch of brew dependencies. Subsequent PHP versions will install faster.
Note: You no longer have to unlink each version between installing PHP versions as they are not linked by default
Also, you may have the need to tweak configuration settings of PHP to your needs. A common thing to change is the memory setting, or the date.timezone configuration. The php.ini files for each version of PHP are located in the following directories:
$ brew unlink php@7.3 && brew link --force --overwrite php@5.6
Info: At this point, I strongly recommend closing ALL your terminal tabs and windows. This will mean opening a new terminal to continue with the next step. This is strongly recommended because some really strange path issues can arise with existing terminals (trust me, I have seen it!).
Quick test that we’re in the correct version:
1 2 3 4 5 6
php -v
PHP 5.6.39 (cli) (built: Dec 7 2018 08:27:47) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
安装php之前,请先用brew tap命令引入第三方的php库,brew仓库中没有php的安装包。
1 2 3
brew update # 安装软件前都要习惯的更新下brew源 brew tap homebrew/dupes brew tap josegonzalez/homebrew-php
13 [global] 14 ; Pid file 15 ; Note: the default prefix is /usr/local/var 16 ; Default Value: none 17 ;pid = run/php-fpm.pid 18 19 ; Error log file 20 ; If it's set to "syslog", log is sent to syslogd instead of being written 21 ; in a local file. 22 ; Note: the default prefix is /usr/local/var 23 ; Default Value: log/php-fpm.log 24 ;error_log = log/php-fpm.log
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.2.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring nginx-1.10.2.sierra.bottle.tar.gz ==> Using the sandbox ==> Caveats Docroot is: /usr/local/var/www
The default port has been setin /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To have launchd start nginx now and restart at login: brew services start nginx Or, if you don't want/need a background service you can just run: nginx ==> Summary
➜ servers sudo nginx -t nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful