mac lamp环境配置

LNMP

nginx

  1. brew install nginx
  2. Updating Homebrew...
  3. ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.3.sierra.bottle.tar.gz
  4. Already downloaded: /Users/mini/Library/Caches/Homebrew/nginx-1.10.3.sierra.bottle.tar.gz
  5. ==> Pouring nginx-1.10.3.sierra.bottle.tar.gz
  6. ==> Using the sandbox
  7. ==> Caveats
  8. Docroot is: /usr/local/var/www
  9. The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
  10. nginx can run without sudo.
  11. nginx will load all files in /usr/local/etc/nginx/servers/.
  12. To have launchd start nginx now and restart at login:
  13. brew services start nginx
  14. Or, if you don't want/need a background service you can just run:
  15. nginx
  16. ==> Summary
  17. 🍺 /usr/local/Cellar/nginx/1.10.3: 8 files, 980.9K
  1. #重新加载配置|重启|停止|退出 nginx
  2. nginx -s reload|reopen|stop|quit
  3. #测试配置是否有语法错误
  4. nginx -t

Mysql

  1. brew install mysql
  2. ==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.17.sierra.bottle.1.tar.gz
  3. Already downloaded: /Users/mini/Library/Caches/Homebrew/mysql-5.7.17.sierra.bottle.1.tar.gz
  4. ==> Pouring mysql-5.7.17.sierra.bottle.1.tar.gz
  5. ==> Using the sandbox
  6. ==> Caveats
  7. We've installed your MySQL database without a root password. To secure it run:
  8. mysql_secure_installation
  9. To connect run:
  10. mysql -uroot
  11. To have launchd start mysql now and restart at login:
  12. brew services start mysql
  13. Or, if you don't want/need a background service you can just run:
  14. mysql.server start
  15. ==> Summary
  16. 🍺 /usr/local/Cellar/mysql/5.7.17: 321 files, 234.4M

PHP5.6

  1. brew install php56 --with-imap --with-tidy --with-debug --with-mysql --with-fpm
  2. Updating Homebrew...
  3. ==> Installing php56 from josegonzalez/php
  4. ==> Installing dependencies for josegonzalez/php/php56: imap-uw
  5. ==> Installing josegonzalez/php/php56 dependency: imap-uw
  6. ==> Downloading https://homebrew.bintray.com/bottles/imap-uw-2007f.sierra.bottle.tar.gz
  7. ######################################################################## 100.0%
  8. ==> Pouring imap-uw-2007f.sierra.bottle.tar.gz
  9. 🍺 /usr/local/Cellar/imap-uw/2007f: 151 files, 9.0M
  10. Warning: josegonzalez/php/php56: this formula has no --with-fpm option so it will be ignored!
  11. Warning: josegonzalez/php/php56: this formula has no --with-mysql option so it will be ignored!
  12. Warning: josegonzalez/php/php56: this formula has no --with-tidy option so it will be ignored!
  13. ==> Installing josegonzalez/php/php56 --with-debug --with-imap
  14. ==> Downloading https://php.net/get/php-5.6.29.tar.bz2/from/this/mirror
  15. ==> Downloading from https://secure.php.net/distributions/php-5.6.29.tar.bz2
  16. ######################################################################## 100.0%
  17. ==> ./configure --prefix=/usr/local/Cellar/php56/5.6.29_5 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/5.6 --with-config-fil
  18. ==> make
  19. ==> make install
  20. ==> Caveats
  21. The php.ini file can be found in:
  22. /usr/local/etc/php/5.6/php.ini
  23. ✩✩✩✩ Extensions ✩✩✩✩
  24. If you are having issues with custom extension compiling, ensure that
  25. you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
  26. PATH="/usr/local/bin:$PATH"
  27. PHP56 Extensions will always be compiled against this PHP. Please install them
  28. using --without-homebrew-php to enable compiling against system PHP.
  29. ✩✩✩✩ PHP CLI ✩✩✩✩
  30. If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
  31. ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
  32. export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
  33. ✩✩✩✩ FPM ✩✩✩✩
  34. To launch php-fpm on startup:
  35. mkdir -p ~/Library/LaunchAgents
  36. cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
  37. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
  38. The control script is located at /usr/local/opt/php56/sbin/php56-fpm
  39. 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:
  40. PATH="/usr/local/sbin:$PATH"
  41. You may also need to edit the plist to use the correct "UserName".
  42. Please note that the plist was called 'homebrew-php.josegonzalez.php56.plist' in old versions
  43. of this formula.
  44. With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system
  45. you have to install php with the --with-httpd24 option. See brew options php56 for more details.
  46. To have launchd start josegonzalez/php/php56 now and restart at login:
  47. brew services start josegonzalez/php/php56
  48. ==> Summary
  49. 🍺 /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

相关服务

  1. 停止自带的apache

sudo apachectl stop 
or 
sudo lsof -i -P | grep 80

  1. or Try this
  2. `which apachectl`
  3. on my mavericks I get
  4. `/usr/sbin/apachectl`
  5. then
  6. `sudo /usr/sbin/apachectl stop`

brew tap

  1. brew tap josegonzalez/homebrew-php
  2. Updating Homebrew...
  3. ==> Auto-updated Homebrew!
  4. Updated 2 taps (homebrew/core, josegonzalez/php).
  5. ==> New Formulae
  6. ktmpl
  7. ==> Updated Formulae
  8. certigo jigdo josegonzalez/php/php55-redis mysql-cluster wolfssl
  9. digdag josegonzalez/php/php53-redis josegonzalez/php/php56-redis skinny yank
  10. embulk josegonzalez/php/php54-redis josegonzalez/php/php71-redis swiftgen

composer

  1. ~ brew install josegonzalez/php/composer
  2. ==> Installing composer from josegonzalez/php
  3. ==> Downloading https://homebrew.bintray.com/bottles-php/composer-1.3.2.sierra.bottle.tar.gz
  4. ######################################################################## 100.0%
  5. ==> Pouring composer-1.3.2.sierra.bottle.tar.gz
  6. 🍺 /usr/local/Cellar/composer/1.3.2: 5 files, 1.7M

crontab

  1. crontab -e 编写定时任务
  2. crontab -l 查看定时任务

log

  1. /usr/local/var/log/...

php-xdebug(报异常)

  1. ~ brew install php56-xdebug
  2. Updating Homebrew...
  3. ==> Auto-updated Homebrew!
  4. Updated 2 taps (homebrew/core, homebrew/dupes).
  5. ==> New Formulae
  6. git-quick-stats uftp
  7. ==> Updated Formulae
  8. aha buku compcert geoserver gst-plugins-base homebrew/dupes/ed libhdhomerun mosquitto putty tile38
  9. akka bullet crystal-lang gitlab-ci-multi-runner gst-plugins-good imagemagick libphonenumber mpd qca vim
  10. arangodb casperjs curl gnome-autoar gst-plugins-ugly jenkins libsigsegv node ringojs wakatime-cli
  11. aws-sdk-cpp charm direnv gradle gst-python jump mecab-jumandic node-build rust xonsh
  12. awscli cheops docker-compose gst-editing-services gst-rtsp-server kerl mitmproxy nvm sops yaz
  13. azure-cli cjdns docker-compose-completion gst-libav gst-validate kobalt mkvtoolnix osc svtplay-dl youtube-dl
  14. bee coffeescript elixirscript gst-plugins-bad gstreamer libarchive mongo-orchestration parallel terragrunt zstd
  15. ==> Renamed Formulae
  16. protobuf250 -> protobuf@2.5 protobuf260 -> protobuf@2.6
  17. ==> Deleted Formulae
  18. malaga probatron4j rtpbreak suomi-malaga-voikko
  19. ==> Installing php56-xdebug from josegonzalez/php
  20. ==> Downloading https://homebrew.bintray.com/bottles-php/php56-xdebug-2.5.0.sierra.bottle.tar.gz
  21. ######################################################################## 100.0%
  22. ==> Pouring php56-xdebug-2.5.0.sierra.bottle.tar.gz
  23. ==> Caveats
  24. To finish installing xdebug for PHP 5.6:
  25. * /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini was created,
  26. do not forget to remove it upon extension removal.
  27. * Validate installation via one of the following methods:
  28. *
  29. * Using PHP from a webserver:
  30. * - Restart your webserver.
  31. * - Write a PHP page that calls "phpinfo();"
  32. * - Load it in a browser and look for the info on the xdebug module.
  33. * - If you see it, you have been successful!
  34. *
  35. * Using PHP from the command line:
  36. * - Run `php -i "(command-line 'phpinfo()')"`
  37. * - Look for the info on the xdebug module.
  38. * - If you see it, you have been successful!
  39. ==> Summary
  40. 🍺 /usr/local/Cellar/php56-xdebug/2.5.0: 3 files, 194.1K

autoconf

  1. ~ brew install autoconf
  2. Updating Homebrew...
  3. ==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz
  4. ######################################################################## 100.0%
  5. ==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz
  6. ==> Caveats
  7. Emacs Lisp files have been installed to:
  8. /usr/local/share/emacs/site-lisp/autoconf
  9. ==> Summary
  10. 🍺 /usr/local/Cellar/autoconf/2.69: 70 files, 3.0M

PHP多版本

  1. ~ brew install php70 --without-apache --with-fpm
  2. Updating Homebrew...
  3. ==> Auto-updated Homebrew!
  4. Updated 1 tap (homebrew/core).
  5. ==> Updated Formulae
  6. couchdb-lucene fonttools harfbuzz json-fortran meson
  7. ==> Installing php70 from josegonzalez/php
  8. Error: Cannot install josegonzalez/php/php70 because conflicting formulae are installed.
  9. php56: because different php versions install the same binaries.
  10. Please `brew unlink php56` before continuing.
  11. Unlinking removes a formula's symlinks from /usr/local. You can
  12. link the formula again after the install finishes. You can --force this
  13. install, but the build may fail or cause obscure side-effects in the
  14. resulting software.
  15. ➜ ~ brew unlink php56
  16. Unlinking /usr/local/Cellar/php56/5.6.29_5... 17 symlinks removed
  17. ➜ ~ brew install php70
  18. Updating Homebrew...
  19. ==> Auto-updated Homebrew!
  20. Updated 1 tap (homebrew/core).
  21. ==> Updated Formulae
  22. midnight-commander protobuf-swift vegeta
  23. ==> Installing php70 from josegonzalez/php
  24. ==> Installing dependencies for josegonzalez/php/php70: readline
  25. ==> Installing josegonzalez/php/php70 dependency: readline
  26. ==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.3.sierra.bottle.tar.gz
  27. ######################################################################## 100.0%
  28. ==> Pouring readline-7.0.3.sierra.bottle.tar.gz
  29. ==> Caveats
  30. This formula is keg-only, which means it was not symlinked into /usr/local.
  31. macOS provides the BSD libedit library, which shadows libreadline.
  32. In order to prevent conflicts when programs look for libreadline we are
  33. defaulting this GNU Readline installation to keg-only.
  34. For compilers to find this software you may need to set:
  35. LDFLAGS: -L/usr/local/opt/readline/lib
  36. CPPFLAGS: -I/usr/local/opt/readline/include
  37. ==> Summary
  38. 🍺 /usr/local/Cellar/readline/7.0.3: 46 files, 2M
  39. ==> Installing josegonzalez/php/php70
  40. ==> Downloading https://homebrew.bintray.com/bottles-php/php70-7.0.15_8.sierra.bottle.tar.gz
  41. ######################################################################## 100.0%
  42. ==> Pouring php70-7.0.15_8.sierra.bottle.tar.gz
  43. ==> Caveats
  44. The php.ini file can be found in:
  45. /usr/local/etc/php/7.0/php.ini
  46. ✩✩✩✩ Extensions ✩✩✩✩
  47. If you are having issues with custom extension compiling, ensure that
  48. you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
  49. PATH="/usr/local/bin:$PATH"
  50. PHP70 Extensions will always be compiled against this PHP. Please install them
  51. using --without-homebrew-php to enable compiling against system PHP.
  52. ✩✩✩✩ PHP CLI ✩✩✩✩
  53. If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
  54. ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
  55. export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"
  56. ✩✩✩✩ FPM ✩✩✩✩
  57. To launch php-fpm on startup:
  58. mkdir -p ~/Library/LaunchAgents
  59. cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/
  60. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
  61. The control script is located at /usr/local/opt/php70/sbin/php70-fpm
  62. 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:
  63. PATH="/usr/local/sbin:$PATH"
  64. You may also need to edit the plist to use the correct "UserName".
  65. Please note that the plist was called 'homebrew-php.josegonzalez.php70.plist' in old versions
  66. of this formula.
  67. With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system
  68. you have to install php with the --with-httpd24 option. See brew options php70 for more details.
  69. To have launchd start josegonzalez/php/php70 now and restart at login:
  70. brew services start josegonzalez/php/php70
  71. ==> Summary
  72. 🍺 /usr/local/Cellar/php70/7.0.15_8: 332 files, 38.8M

php-version

  1. ~ brew install php-version
  2. Updating Homebrew...
  3. ==> Installing php-version from josegonzalez/php
  4. ==> Downloading https://homebrew.bintray.com/bottles-php/php-version-0.12.1.sierra.bottle.tar.gz
  5. ######################################################################## 100.0%
  6. ==> Pouring php-version-0.12.1.sierra.bottle.tar.gz
  7. ==> Caveats
  8. Add the following to $HOME/.bashrc, $HOME/.zshrc, or your shell's equivalent configuration file:
  9. source $(brew --prefix php-version)/php-version.sh && php-version 5
  10. It is recommended that you install versions of PHP via homebrew as depicted below:
  11. brew install php56
  12. brew unlink php56
  13. Type `php-version --help` for more configuration options.
  14. ==> Summary
  15. 🍺 /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

  1. ~ brew install mongodb
  2. Updating Homebrew...
  3. ==> Auto-updated Homebrew!
  4. Updated 2 taps (homebrew/core, homebrew/dupes).
  5. ==> New Formulae
  6. bit dmtx-utils sha1dc
  7. ==> Updated Formulae
  8. aptly-completion grails pdfgrep
  9. armor grpc pgcli
  10. aws-sdk-cpp hg-flow proselint
  11. awscli hledger protobuf-swift
  12. bash-completion hyper pyinvoke
  13. byteman i3status reposurgeon
  14. cake iperf3 rmlint
  15. cassandra ipfs selenium-server-standalone
  16. certigo jenkins spdlog
  17. conan jrnl sqlparse
  18. consul-backinator khal stout
  19. convox kompose svgcleaner
  20. crystal-icr kubernetes-helm swiftformat
  21. crystal-lang ldc swiftplate
  22. csvtomd libav swimat
  23. curlpp libbluray syncthing
  24. dosfstools libosmium tarsnapper
  25. eralchemy linkerd timelimit
  26. eventql mandoc todolist
  27. excel-compare metricbeat todoman
  28. feedgnuplot mighttpd2 tundra
  29. gcc@4.9 minimesos typescript
  30. git-lfs newlisp vert.x
  31. git-quick-stats nexus vim
  32. gnutls p11-kit yle-dl
  33. goaccess packetbeat youtube-dl
  34. gofabric8 paket
  35. ==> Renamed Formulae
  36. bash-completion2 -> bash-completion@2 mariadb100 -> mariadb@10.0
  37. ==> Deleted Formulae
  38. ctorrent s3sync
  39. ==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.4.2.sierra.bottle.1.ta
  40. ############## 20.7%
  41. curl: (18) transfer closed with 74649928 bytes remaining to read
  42. Error: Failed to download resource "mongodb"
  43. Download failed: https://homebrew.bintray.com/bottles/mongodb-3.4.2.sierra.bottle.1.tar.gz
  44. Warning: Bottle installation failed: building from source.
  45. ==> Installing dependencies for mongodb: go, scons
  46. ==> Installing mongodb dependency: go
  47. ==> Downloading https://homebrew.bintray.com/bottles/go-1.8.sierra.bottle.tar.gz
  48. ######################################################################## 100.0%
  49. ==> Pouring go-1.8.sierra.bottle.tar.gz
  50. ==> Caveats
  51. A valid GOPATH is required to use the `go get` command.
  52. If $GOPATH is not specified, $HOME/go will be used by default:
  53. https://golang.org/doc/code.html#GOPATH
  54. You may wish to add the GOROOT-based install location to your PATH:
  55. export PATH=$PATH:/usr/local/opt/go/libexec/bin
  56. ==> Summary
  57. 🍺 /usr/local/Cellar/go/1.8: 7,017 files, 281.6MB
  58. ==> Installing mongodb dependency: scons
  59. ==> Downloading https://homebrew.bintray.com/bottles/scons-2.5.1.sierra.bottle.tar.gz
  60. ######################################################################## 100.0%
  61. ==> Pouring scons-2.5.1.sierra.bottle.tar.gz
  62. 🍺 /usr/local/Cellar/scons/2.5.1: 209 files, 2.2MB
  63. ==> Using the sandbox
  64. ==> Downloading https://fastdl.mongodb.org/src/mongodb-src-r3.4.2.tar.gz
  65. ######################################################################## 100.0%
  66. ==> Cloning https://github.com/mongodb/mongo-tools.git
  67. Cloning into '/Users/mini/Library/Caches/Homebrew/mongodb--github.com-mongodb-mongo-tools--git'...
  68. remote: Counting objects: 20140, done.
  69. remote: Compressing objects: 100% (47/47), done.
  70. remote: Total 20140 (delta 22), reused 0 (delta 0), pack-reused 20092
  71. Receiving objects: 100% (20140/20140), 9.56 MiB | 382.00 KiB/s, done.
  72. Resolving deltas: 100% (9926/9926), done.
  73. Note: checking out '17fbdf31abca50cdfe27482b05b1476f42ecab0a'.
  74. You are in 'detached HEAD' state. You can look around, make experimental
  75. changes and commit them, and you can discard any commits you make in this
  76. state without impacting any branches by performing another checkout.
  77. If you want to create a new branch to retain commits you create, you may
  78. do so (now or later) by using -b with the checkout command again. Example:
  79. git checkout -b <new-branch-name>
  80. ==> Checking out tag r3.4.2
  81. ==> ./build.sh ssl
  82. ==> /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
  83. ==> Caveats
  84. To have launchd start mongodb now and restart at login:
  85. brew services start mongodb
  86. Or, if you don't want/need a background service you can just run:
  87. mongod --config /usr/local/etc/mongod.conf
  88. ==> Summary
  89. 🍺 /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

  1. vhost brew install php56-mongodb
  2. Updating Homebrew...
  3. ==> Auto-updated Homebrew!
  4. Updated 1 tap (homebrew/core).
  5. ==> Updated Formulae
  6. alot aws-sdk-cpp awscli botan doitlive jid kubernetes-cli lxc mikutter monit monotone softhsm sourcery vim
  7. ==> Installing php56-mongodb from josegonzalez/php
  8. ==> Downloading https://homebrew.bintray.com/bottles-php/php56-mongodb-1.2.5.sierra.bottle.tar.gz
  9. ######################################################################## 100.0%
  10. ==> Pouring php56-mongodb-1.2.5.sierra.bottle.tar.gz
  11. ==> Caveats
  12. To finish installing mongodb for PHP 5.6:
  13. * /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini was created,
  14. do not forget to remove it upon extension removal.
  15. * Validate installation via one of the following methods:
  16. *
  17. * Using PHP from a webserver:
  18. * - Restart your webserver.
  19. * - Write a PHP page that calls "phpinfo();"
  20. * - Load it in a browser and look for the info on the mongodb module.
  21. * - If you see it, you have been successful!
  22. *
  23. * Using PHP from the command line:
  24. * - Run `php -i "(command-line 'phpinfo()')"`
  25. * - Look for the info on the mongodb module.
  26. * - If you see it, you have been successful!
  27. ==> Summary
  28. 🍺 /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/

posted @ 2017-07-12 11:55  zgj12306  阅读(796)  评论(0)    收藏  举报