• 隐藏侧边栏
  • 展开分类目录
  • 关注微信公众号
  • 我的GitHub
  • QQ:1753970025
Chen Jiehua

Mac之Homebrew 

目录

Homebrew是OS X下一个非常不错的套件管理器,大大简化了许多软件的安装~~~

Homebrew安装

官方网站:http://brew.sh/index_zh-cn.html

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

默认安装在/usr/local,后续软件则安装在/usr/local/Cellar中,同时软链到/usr/local/bin

brew命令:

brew install
brew uninstall
brew list     #列出已安装的软件
brew update   #更新brew
brew home     #用浏览器打开brew的官方网站
brew info     #显示软件信息
brew deps     #显示包依赖

使用文档地址:https://git.io/brew-docs,如果brew install提示错误时,一般可以试试brew update更新一下软件源,或者brew doctor查看一下问题。

 

Nginx安装

brew install nginx
Installing dependencies for nginx: pcre, openssl
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

 LDFLAGS: -L/usr/local/opt/openssl/lib
 CPPFLAGS: -I/usr/local/opt/openssl/include

$ ./configure --prefix=/usr/local/Cellar/nginx/1.6.2 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.6.2/bin/nginx --wi
$ make
$ make install
$ CaveatsDocroot 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.

To have launchd start nginx at login:
 ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
 launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
 nginx

其他命令:

sudo nginx    #打开 nginx
nginx -t      #测试配置是否有语法错误
nginx -s reload|reopen|stop|quit    #重新加载配置|重启|停止|退出 nginx

关闭Apache自动启动

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

MySQL安装

brew install mysql
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
mysql -uroot

To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start

其他命令:

mysql.server start    #开启服务
mysql.server stop     #停止服务
mysqladmin -u root password 'xxx'   #给root设置密码
mysql -uroot -p    #连接数据库

 

PHP安装

brew install php56 --with-fpm
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so

The 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 that
you 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 them
using --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/LaunchAgents
cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

The control script is located at /usr/local/opt/php56/sbin/php56-fpm

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:

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 versions
of this formula.

To have launchd start homebrew/php/php56 at login:
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
Then to load homebrew/php/php56 now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

配置Nginx需要注意:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 

phpmyadmin安装

brew install phpmyadmin
Note that this formula will NOT install mysql. It is not
required since you might want to get connected to a remote
database server.

Webserver configuration example (add this at the end of
your /etc/apache2/httpd.conf for instance) :
 Alias /phpmyadmin /usr/local/share/phpmyadmin
 <Directory /usr/local/share/phpmyadmin/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 <IfModule mod_authz_core.c>
 Require all granted
 </IfModule>
 <IfModule !mod_authz_core.c>
 Order allow,deny
 Allow from all
 </IfModule>
 </Directory>
Then, open http://localhost/phpmyadmin

More documentation : file:///usr/local/Cellar/phpmyadmin/4.4.11/share/phpmyadmin/doc/

Configuration has been copied to /usr/local/etc/phpmyadmin.config.inc.php
Don't forget to:
 - change your secret blowfish
 - uncomment the configuration lines (pma, pmapass ...)

 

Redis安装

brew install redis
To have launchd start redis at login:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
redis-server /usr/local/etc/redis.conf

 

Mongo安装

brew install mongo
To have launchd start mongodb at login:
 ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
 launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
 mongod --config /usr/local/etc/mongod.conf

 

 

常用软件安装笔记

brew install mysql

mysql.server start | stop

brew install nginx

/usr/local/etc/nginx/nginx.conf

easy_install pip

pip install supervisor

pip install virtualenv

echo_supervisord_conf > /etc/supervisord.conf

 

码字很辛苦,转载请注明来自ChenJiehua《Mac之Homebrew》

评论