mac lamp环境配置
LNMP
nginx
brew install nginxUpdating Homebrew...==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.3.sierra.bottle.tar.gzAlready downloaded: /Users/mini/Library/Caches/Homebrew/nginx-1.10.3.sierra.bottle.tar.gz==> Pouring nginx-1.10.3.sierra.bottle.tar.gz==> Using the sandbox==> CaveatsDocroot is: /usr/local/var/wwwThe default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so thatnginx 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 nginxOr, if you don't want/need a background service you can just run:nginx==> Summary🍺 /usr/local/Cellar/nginx/1.10.3: 8 files, 980.9K
#重新加载配置|重启|停止|退出 nginxnginx -s reload|reopen|stop|quit#测试配置是否有语法错误nginx -t
Mysql
brew install mysql==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.17.sierra.bottle.1.tar.gzAlready downloaded: /Users/mini/Library/Caches/Homebrew/mysql-5.7.17.sierra.bottle.1.tar.gz==> Pouring mysql-5.7.17.sierra.bottle.1.tar.gz==> Using the sandbox==> CaveatsWe've installed your MySQL database without a root password. To secure it run:mysql_secure_installationTo connect run:mysql -urootTo have launchd start mysql now and restart at login:brew services start mysqlOr, if you don't want/need a background service you can just run:mysql.server start==> Summary🍺 /usr/local/Cellar/mysql/5.7.17: 321 files, 234.4M
PHP5.6
brew install php56 --with-imap --with-tidy --with-debug --with-mysql --with-fpmUpdating Homebrew...==> Installing php56 from josegonzalez/php==> Installing dependencies for josegonzalez/php/php56: imap-uw==> Installing josegonzalez/php/php56 dependency: imap-uw==> Downloading https://homebrew.bintray.com/bottles/imap-uw-2007f.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring imap-uw-2007f.sierra.bottle.tar.gz🍺 /usr/local/Cellar/imap-uw/2007f: 151 files, 9.0MWarning: josegonzalez/php/php56: this formula has no --with-fpm option so it will be ignored!Warning: josegonzalez/php/php56: this formula has no --with-mysql option so it will be ignored!Warning: josegonzalez/php/php56: this formula has no --with-tidy option so it will be ignored!==> Installing josegonzalez/php/php56 --with-debug --with-imap==> Downloading https://php.net/get/php-5.6.29.tar.bz2/from/this/mirror==> Downloading from https://secure.php.net/distributions/php-5.6.29.tar.bz2######################################################################## 100.0%==> ./configure --prefix=/usr/local/Cellar/php56/5.6.29_5 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/5.6 --with-config-fil==> make==> make install==> CaveatsThe php.ini file can be found in:/usr/local/etc/php/5.6/php.ini✩✩✩✩ Extensions ✩✩✩✩If you are having issues with custom extension compiling, ensure thatyou are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:PATH="/usr/local/bin:$PATH"PHP56 Extensions will always be compiled against this PHP. Please install themusing --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/php56)/bin:$PATH"✩✩✩✩ FPM ✩✩✩✩To launch php-fpm on startup:mkdir -p ~/Library/LaunchAgentscp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plistThe control script is located at /usr/local/opt/php56/sbin/php56-fpmOS 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.php56.plist' in old versionsof 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 systemyou have to install php with the --with-httpd24 option. See brew options php56 for more details.To have launchd start josegonzalez/php/php56 now and restart at login:brew services start josegonzalez/php/php56==> Summary🍺 /usr/local/Cellar/php56/5.6.29_5: 331 files, 43.1M, built in 7 minutes 7 seconds
php-fpm -t 测试php-fpm配置
重启php-fpm:
killall php-fpm
/usr/local/sbin/php-fpm
相关服务
停止自带的apache:
sudo apachectl stop
or
sudo lsof -i -P | grep 80
or Try this`which apachectl`on my mavericks I get`/usr/sbin/apachectl`then`sudo /usr/sbin/apachectl stop`
brew tap
brew tap josegonzalez/homebrew-phpUpdating Homebrew...==> Auto-updated Homebrew!Updated 2 taps (homebrew/core, josegonzalez/php).==> New Formulaektmpl==> Updated Formulaecertigo jigdo josegonzalez/php/php55-redis mysql-cluster wolfssldigdag josegonzalez/php/php53-redis josegonzalez/php/php56-redis skinny yankembulk josegonzalez/php/php54-redis josegonzalez/php/php71-redis swiftgen
composer
➜ ~ brew install josegonzalez/php/composer==> Installing composer from josegonzalez/php==> Downloading https://homebrew.bintray.com/bottles-php/composer-1.3.2.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring composer-1.3.2.sierra.bottle.tar.gz🍺 /usr/local/Cellar/composer/1.3.2: 5 files, 1.7M
crontab
crontab -e 编写定时任务crontab -l 查看定时任务
log
/usr/local/var/log/...
php-xdebug(报异常)
➜ ~ brew install php56-xdebugUpdating Homebrew...==> Auto-updated Homebrew!Updated 2 taps (homebrew/core, homebrew/dupes).==> New Formulaegit-quick-stats uftp==> Updated Formulaeaha buku compcert geoserver gst-plugins-base homebrew/dupes/ed libhdhomerun mosquitto putty tile38akka bullet crystal-lang gitlab-ci-multi-runner gst-plugins-good imagemagick libphonenumber mpd qca vimarangodb casperjs curl gnome-autoar gst-plugins-ugly jenkins libsigsegv node ringojs wakatime-cliaws-sdk-cpp charm direnv gradle gst-python jump mecab-jumandic node-build rust xonshawscli cheops docker-compose gst-editing-services gst-rtsp-server kerl mitmproxy nvm sops yazazure-cli cjdns docker-compose-completion gst-libav gst-validate kobalt mkvtoolnix osc svtplay-dl youtube-dlbee coffeescript elixirscript gst-plugins-bad gstreamer libarchive mongo-orchestration parallel terragrunt zstd==> Renamed Formulaeprotobuf250 -> protobuf@2.5 protobuf260 -> protobuf@2.6==> Deleted Formulaemalaga probatron4j rtpbreak suomi-malaga-voikko==> Installing php56-xdebug from josegonzalez/php==> Downloading https://homebrew.bintray.com/bottles-php/php56-xdebug-2.5.0.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring php56-xdebug-2.5.0.sierra.bottle.tar.gz==> CaveatsTo finish installing xdebug for PHP 5.6:* /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini was created,do not forget to remove it upon extension removal.* Validate installation via one of the following methods:** Using PHP from a webserver:* - Restart your webserver.* - Write a PHP page that calls "phpinfo();"* - Load it in a browser and look for the info on the xdebug module.* - If you see it, you have been successful!** Using PHP from the command line:* - Run `php -i "(command-line 'phpinfo()')"`* - Look for the info on the xdebug module.* - If you see it, you have been successful!==> Summary🍺 /usr/local/Cellar/php56-xdebug/2.5.0: 3 files, 194.1K
autoconf
➜ ~ brew install autoconfUpdating Homebrew...==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz######################################################################## 100.0%==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz==> CaveatsEmacs Lisp files have been installed to:/usr/local/share/emacs/site-lisp/autoconf==> Summary🍺 /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M
PHP多版本
➜ ~ brew install php70 --without-apache --with-fpmUpdating Homebrew...==> Auto-updated Homebrew!Updated 1 tap (homebrew/core).==> Updated Formulaecouchdb-lucene fonttools harfbuzz json-fortran meson==> Installing php70 from josegonzalez/phpError: Cannot install josegonzalez/php/php70 because conflicting formulae are installed.php56: because different php versions install the same binaries.Please `brew unlink php56` before continuing.Unlinking removes a formula's symlinks from /usr/local. You canlink the formula again after the install finishes. You can --force thisinstall, but the build may fail or cause obscure side-effects in theresulting software.➜ ~ brew unlink php56Unlinking /usr/local/Cellar/php56/5.6.29_5... 17 symlinks removed➜ ~ brew install php70Updating Homebrew...==> Auto-updated Homebrew!Updated 1 tap (homebrew/core).==> Updated Formulaemidnight-commander protobuf-swift vegeta==> Installing php70 from josegonzalez/php==> Installing dependencies for josegonzalez/php/php70: readline==> Installing josegonzalez/php/php70 dependency: readline==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.3.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring readline-7.0.3.sierra.bottle.tar.gz==> CaveatsThis formula is keg-only, which means it was not symlinked into /usr/local.macOS provides the BSD libedit library, which shadows libreadline.In order to prevent conflicts when programs look for libreadline we aredefaulting this GNU Readline installation to keg-only.For compilers to find this software you may need to set:LDFLAGS: -L/usr/local/opt/readline/libCPPFLAGS: -I/usr/local/opt/readline/include==> Summary🍺 /usr/local/Cellar/readline/7.0.3: 46 files, 2M==> Installing josegonzalez/php/php70==> Downloading https://homebrew.bintray.com/bottles-php/php70-7.0.15_8.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring php70-7.0.15_8.sierra.bottle.tar.gz==> CaveatsThe 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 thatyou 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 themusing --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"✩✩✩✩ FPM ✩✩✩✩To launch php-fpm on startup:mkdir -p ~/Library/LaunchAgentscp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plistThe control script is located at /usr/local/opt/php70/sbin/php70-fpmOS 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 versionsof 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 systemyou have to install php with the --with-httpd24 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==> Summary🍺 /usr/local/Cellar/php70/7.0.15_8: 332 files, 38.8M
php-version
➜ ~ brew install php-versionUpdating Homebrew...==> Installing php-version from josegonzalez/php==> Downloading https://homebrew.bintray.com/bottles-php/php-version-0.12.1.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring php-version-0.12.1.sierra.bottle.tar.gz==> CaveatsAdd the following to $HOME/.bashrc, $HOME/.zshrc, or your shell's equivalent configuration file:source $(brew --prefix php-version)/php-version.sh && php-version 5It is recommended that you install versions of PHP via homebrew as depicted below:brew install php56brew unlink php56Type `php-version --help` for more configuration options.==> Summary🍺 /usr/local/Cellar/php-version/0.12.1: 6 files, 15.6K
➜ ~ sudo vim ~/.zshrc
➜ ~ source $(brew –prefix php-version)/php-version.sh && php-version 5
➜ ~ php-version
- 5.6.29
7.0.15
➜ ~ php -v
PHP 5.6.29 (cli) (built: Feb 20 2017 18:27:53) (DEBUG)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
➜ ~ php-version 7
➜ ~ php -v
PHP 7.0.15 (cli) (built: Jan 22 2017 08:51:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
➜ ~ php-version 5
➜ ~ php -v
PHP 5.6.29 (cli) (built: Feb 20 2017 18:27:53) (DEBUG)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
MongoDb
➜ ~ brew install mongodbUpdating Homebrew...==> Auto-updated Homebrew!Updated 2 taps (homebrew/core, homebrew/dupes).==> New Formulaebit dmtx-utils sha1dc==> Updated Formulaeaptly-completion grails pdfgreparmor grpc pgcliaws-sdk-cpp hg-flow proselintawscli hledger protobuf-swiftbash-completion hyper pyinvokebyteman i3status reposurgeoncake iperf3 rmlintcassandra ipfs selenium-server-standalonecertigo jenkins spdlogconan jrnl sqlparseconsul-backinator khal stoutconvox kompose svgcleanercrystal-icr kubernetes-helm swiftformatcrystal-lang ldc swiftplatecsvtomd libav swimatcurlpp libbluray syncthingdosfstools libosmium tarsnappereralchemy linkerd timelimiteventql mandoc todolistexcel-compare metricbeat todomanfeedgnuplot mighttpd2 tundragcc@4.9 minimesos typescriptgit-lfs newlisp vert.xgit-quick-stats nexus vimgnutls p11-kit yle-dlgoaccess packetbeat youtube-dlgofabric8 paket==> Renamed Formulaebash-completion2 -> bash-completion@2 mariadb100 -> mariadb@10.0==> Deleted Formulaectorrent s3sync==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.4.2.sierra.bottle.1.ta############## 20.7%curl: (18) transfer closed with 74649928 bytes remaining to readError: Failed to download resource "mongodb"Download failed: https://homebrew.bintray.com/bottles/mongodb-3.4.2.sierra.bottle.1.tar.gzWarning: Bottle installation failed: building from source.==> Installing dependencies for mongodb: go, scons==> Installing mongodb dependency: go==> Downloading https://homebrew.bintray.com/bottles/go-1.8.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring go-1.8.sierra.bottle.tar.gz==> CaveatsA valid GOPATH is required to use the `go get` command.If $GOPATH is not specified, $HOME/go will be used by default:https://golang.org/doc/code.html#GOPATHYou may wish to add the GOROOT-based install location to your PATH:export PATH=$PATH:/usr/local/opt/go/libexec/bin==> Summary🍺 /usr/local/Cellar/go/1.8: 7,017 files, 281.6MB==> Installing mongodb dependency: scons==> Downloading https://homebrew.bintray.com/bottles/scons-2.5.1.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring scons-2.5.1.sierra.bottle.tar.gz🍺 /usr/local/Cellar/scons/2.5.1: 209 files, 2.2MB==> Using the sandbox==> Downloading https://fastdl.mongodb.org/src/mongodb-src-r3.4.2.tar.gz######################################################################## 100.0%==> Cloning https://github.com/mongodb/mongo-tools.gitCloning into '/Users/mini/Library/Caches/Homebrew/mongodb--github.com-mongodb-mongo-tools--git'...remote: Counting objects: 20140, done.remote: Compressing objects: 100% (47/47), done.remote: Total 20140 (delta 22), reused 0 (delta 0), pack-reused 20092Receiving objects: 100% (20140/20140), 9.56 MiB | 382.00 KiB/s, done.Resolving deltas: 100% (9926/9926), done.Note: checking out '17fbdf31abca50cdfe27482b05b1476f42ecab0a'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:git checkout -b <new-branch-name>==> Checking out tag r3.4.2==> ./build.sh ssl==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/3.4.2 -j4 --osx-version-min=10.12 CC=/usr/bin/clang CXX=/usr/bin/clang++ --use-new-tools --disable-warnings-as-errors --ssl CCFLAGS=-I/usr/local/opt/openssl/include LINKFLAGS=-L/usr/local/opt/op==> CaveatsTo have launchd start mongodb now and restart at login:brew services start mongodbOr, if you don't want/need a background service you can just run:mongod --config /usr/local/etc/mongod.conf==> Summary🍺 /usr/local/Cellar/mongodb/3.4.2: 17 files, 266.5MB, built in 45 minutes 46 seconds
brew untap josegonzalez/php
brew tap –repair
brew update
brew tap homebrew/php
php-mongodb
➜ vhost brew install php56-mongodbUpdating Homebrew...==> Auto-updated Homebrew!Updated 1 tap (homebrew/core).==> Updated Formulaealot aws-sdk-cpp awscli botan doitlive jid kubernetes-cli lxc mikutter monit monotone softhsm sourcery vim==> Installing php56-mongodb from josegonzalez/php==> Downloading https://homebrew.bintray.com/bottles-php/php56-mongodb-1.2.5.sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring php56-mongodb-1.2.5.sierra.bottle.tar.gz==> CaveatsTo finish installing mongodb for PHP 5.6:* /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini was created,do not forget to remove it upon extension removal.* Validate installation via one of the following methods:** Using PHP from a webserver:* - Restart your webserver.* - Write a PHP page that calls "phpinfo();"* - Load it in a browser and look for the info on the mongodb module.* - If you see it, you have been successful!** Using PHP from the command line:* - Run `php -i "(command-line 'phpinfo()')"`* - Look for the info on the mongodb module.* - If you see it, you have been successful!==> Summary🍺 /usr/local/Cellar/php56-mongodb/1.2.5: 3 files, 656.3KB
brew services start mongo
brew services stop mongo
mongo DB config:/usr/local/etc/mongo.conf
mongo DB path:/data/db
mongo DB log:/usr/local/var/log/mongo.log
ps aux|grep php
killall php
make
make clean
make test
sudo make install
ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/

浙公网安备 33010602011771号