一、安装Nginx
#brew install nginx
Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae amazon-ecs-cli erlang kubernetes-helm phpmd angular-cli ethereum kustomize prometheus ansible exploitdb languagetool proteinortho apache-flink ffmpeg lgogdownloader protoc-gen-go ask-cli firebase-cli libhdhomerun pyenv atomist-cli fonttools libjson-rpc-cpp pyside aws-sdk-cpp frugal libraw python babel fs-uae libsbol r balena-cli gatsby-cli libvirt redex bazel ghostscript linkerd s3-backer binaryen ginac lmod s3ql bitrise glib log4cplus serverless botan glide log4shib shibboleth-sp bro glooctl logcheck ship caddy goreleaser logstash sip cfn-lint gradle mednafen swagger-codegen chakra gsoap mesa swagger-codegen@2 chipmunk hcloud meson syncthing chronograf helmfile minio sysdig citus hub minio-mc tag ckan hwloc mkl-dnn telegraf cocoapods hypre monit terraform conan igv mono tomcat contentful-cli imagemagick nim tomcat@8 convox isync node u-boot-tools cxxopts janet nsd ucloud dcd jetty ocrmypdf vim@7.4 debianutils jfrog-cli-go opam webdis digdag jhead open-zwave xml-tooling-c dnstwist jlog openapi-generator youtube-dl doitlive jsoncpp openconnect dosbox klavaro openrct2 dscanner kore opensaml ==> Installing dependencies for nginx: openssl and pcre ==> Installing nginx dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottl ==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb ######################################################################## 100.0% ==> Pouring openssl-1.0.2s.mojave.bottle.tar.gz ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" ==> Summary ? /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB ==> Installing nginx dependency: pcre ==> Downloading https://homebrew.bintray.com/bottles/pcre-8.43.mojave.bottle.tar Already downloaded: /Users/apple/Library/Caches/Homebrew/downloads/1b7cb2cf34420d2f3d54b8e13288869193823eaff14a83f0f38be292f7c0e488--pcre-8.43.mojave.bottle.tar.gz ==> Pouring pcre-8.43.mojave.bottle.tar.gz ? /usr/local/Cellar/pcre/8.43: 204 files, 5.5MB ==> Installing nginx ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.17.1.mojave.bottle. ==> Downloading from https://akamai.bintray.com/a1/a1114fd86181db06ebb31c5f3fb5e ######################################################################## 100.0% ==> Pouring nginx-1.17.1.mojave.bottle.tar.gz ==> Caveats Docroot is: /usr/local/var/www The default port has been set in /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 ? /usr/local/Cellar/nginx/1.17.1: 25 files, 2MB ==> Caveats ==> openssl A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local, because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile For compilers to find openssl you may need to set: export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include" ==> nginx Docroot is: /usr/local/var/www The default port has been set in /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
启动和关闭Nginx:
#brew services start nginx
#brew services stop nginx
#brew services restart nginx
查看Nginx的信息:
#nginx -V
二、安装PHP 7
#brew search php
#brew install php@7.2
执行这个命令后,会首先安装PHP的依赖,如果在安装PHP依赖的过程中
(1)出现中断,请重复执行
(2)出现错误,比如出现要求安装Xcode的这个错误:
Error: Xcode alone is not sufficient on Mojave. Install the Command Line Tools: xcode-select --install
按照提示,首先安装最新版的Xcode(如果你的OSX系统不是最新的,需要先将OSX系统升级到最新版才能安装Xcode),然后在命令行执行:
#xcode-select --install
按照提示完成操作即可;下面是PHP安装成功后输出在控制台的部分信息:
==> Installing php@7.2 ==> Downloading https://homebrew.bintray.com/bottles/php@7.2-7.2.20.mojave.bottl ==> Downloading from https://akamai.bintray.com/0e/0e2c39da16d572ebed3edc551a45d ######################################################################## 100.0% ==> Pouring php@7.2-7.2.20.mojave.bottle.tar.gz ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set php_ini /usr/local/etc/ ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set php_dir /usr/local/shar ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set doc_dir /usr/local/shar ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set ext_dir /usr/local/lib/ ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set bin_dir /usr/local/opt/ ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set data_dir /usr/local/sha ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set cfg_dir /usr/local/shar ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set www_dir /usr/local/shar ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set man_dir /usr/local/shar ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set test_dir /usr/local/sha ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear config-set php_bin /usr/local/opt/ ==> /usr/local/Cellar/php@7.2/7.2.20/bin/pear update-channels ==> Caveats To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html The php.ini and php-fpm.ini file can be found in: /usr/local/etc/php/7.2/ php@7.2 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have php@7.2 first in your PATH run: echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile For compilers to find php@7.2 you may need to set: export LDFLAGS="-L/usr/local/opt/php@7.2/lib" export CPPFLAGS="-I/usr/local/opt/php@7.2/include" To have launchd start php@7.2 now and restart at login: brew services start php@7.2 Or, if you don't want/need a background service you can just run: php-fpm ==> Summary ? /usr/local/Cellar/php@7.2/7.2.20: 514 files, 75.0MB ==> Caveats ==> icu4c icu4c is keg-only, which means it was not symlinked into /usr/local, because macOS provides libicucore.dylib (but nothing else). If you need to have icu4c first in your PATH run: echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile For compilers to find icu4c you may need to set: export LDFLAGS="-L/usr/local/opt/icu4c/lib" export CPPFLAGS="-I/usr/local/opt/icu4c/include" For pkg-config to find icu4c you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig" ==> libpq libpq is keg-only, which means it was not symlinked into /usr/local, because conflicts with postgres formula. If you need to have libpq first in your PATH run: echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile For compilers to find libpq you may need to set: export LDFLAGS="-L/usr/local/opt/libpq/lib" export CPPFLAGS="-I/usr/local/opt/libpq/include" For pkg-config to find libpq you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/libpq/lib/pkgconfig" ==> php@7.2 To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html The php.ini and php-fpm.ini file can be found in: /usr/local/etc/php/7.2/ php@7.2 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have php@7.2 first in your PATH run: echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile For compilers to find php@7.2 you may need to set: export LDFLAGS="-L/usr/local/opt/php@7.2/lib" export CPPFLAGS="-I/usr/local/opt/php@7.2/include" To have launchd start php@7.2 now and restart at login: brew services start php@7.2 Or, if you don't want/need a background service you can just run: php-fpm
根据上述提示信息,设置PHP到系统环境变量中:
#echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile
#echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile
三、安装MySQL
#brew search mysql
#brew install mysql@5.5
执行上述命令后,如果中途发生中断,重新执行即可;安装成功后,命令行中输出的部分内容如下:
Updating Homebrew... ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.5-5.5.62.mojave.bot ==> Downloading from https://akamai.bintray.com/69/690a31fbf4e2ee98172b9f861ca2c ######################################################################## 100.0% ==> Pouring mysql@5.5-5.5.62.mojave.bottle.1.tar.gz ==> /usr/local/Cellar/mysql@5.5/5.5.62/bin/mysql_install_db --verbose --user=app ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. MySQL is configured to only allow connections from localhost by default To connect: /usr/local/opt/mysql@5.5/bin/mysql -uroot mysql@5.5 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have mysql@5.5 first in your PATH run: echo 'export PATH="/usr/local/opt/mysql@5.5/bin:$PATH"' >> ~/.bash_profile For compilers to find mysql@5.5 you may need to set: export LDFLAGS="-L/usr/local/opt/mysql@5.5/lib" export CPPFLAGS="-I/usr/local/opt/mysql@5.5/include" To have launchd start mysql@5.5 now and restart at login: brew services start mysql@5.5 Or, if you don't want/need a background service you can just run: /usr/local/opt/mysql@5.5/bin/mysql.server start ==> Summary ? /usr/local/Cellar/mysql@5.5/5.5.62: 320 files, 124.9MB
根据提示,设置MySQL到系统环境变量中:
#echo 'export PATH="/usr/local/opt/mysql@5.5/bin:$PATH"' >> ~/.bash_profile
启动MySQL:
#brew services start mysql@5.5
登录MySQL:
#mysql -uroot -p
如果上述命令提示报错,可能是因为MySQL刚安装完成,重启OSX系统即可,有时候关闭命令窗口重新打开也行,建议重启OSX系统。