本教程适用于centos
安装之前
检查nodejs
假设没安装nodejs依照下面步骤安装$ su - $ yum install openssl-devel$ cd /usr/local/src$ wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz$ tar zxvf node-v0.10.29.tar.gz$ cd node-v0.10.29$ ./configure$ make$ make install查一下版本,看有没有成功安装:
$ node -vv0.10.29
检查git
假设没安装,请依照下面步骤安装
$ sudo yum -y install git
開始安装bower私库
STEP 1 安装 git 和 git-deamon
$ sudo yum install -y git git-daemon
STEP 2 安装 private-bower
$ sudo npm install -g private-bower
STEP 3 设置 private-bower
$ sudo su -$ cd /data$ mkdir private-bower$ vim /data/private-bower-config.json将下面内容粘贴进去:
{ "port": 5678, "registryFile": "./private-bower/bowerRepository.json", "disablePublic": false, "publicRegistry": "http://bower.herokuapp.com/packages/", "repositoryCache": { "git": { "enabled": true, "cacheDirectory": "./private-bower/gitRepoCache", "host": "", "port": 6789 }, "svn": { "enabled": true, "cacheDirectory": "./private-bower/svnRepoCache", "host": " ", "port": 7891 } }, "log4js" : { "enabled": true, "configPath" : "./private-bower/log4js.conf.json" }}
当中的 <bower server ip> 换成你server在外部看起来的ip,由于假设有人已经用过这个库,比方 jquery,再次使用private-bower会让client直接连接server的6789port去获取缓存,所以这个host是给client识别用的
$ vim /data/private-bower/log4js.conf.json
{ "appenders": [ { "type": "dateFile", "filename": "./private-bower/private-bower.log", "pattern": "-yyyy-MM-dd", "alwaysIncludePattern": false }, { "type": "console" } ], "replaceConsole": true}启动 private-bower
$ sudo su -$ cd /data$ private-bower --config ./private-bower-config.json[2014-06-30 10:00:22.481] [INFO] console - [bower] Refreshing public packages...[2014-06-30 10:00:22.512] [INFO] console - [bower] Bower server started on port 5678[2014-06-30 10:00:22.538] [INFO] console - [bower] Starting git cache server[2014-06-30 10:00:22.543] [INFO] console - [bower] Starting svn cache server[2014-06-30 10:01:09.167] [INFO] console - [bower] Loaded public packages确保 private-bower 正常启动: 打开一个新窗体来訪问:
$ lynx http://localhost:5678/会显示: Fork me on GitHub Private Bower ____________________ Docs Public Packages Private Bower service is down No private packages registered read docs about how to register packages. Loading Packages... { { package.name }} hits: { { package.hits }} { { package.repo }} Created by BarnaToth Barna Tóth 假设是这样。就安装完成了
client測试
$ sudo su -$ npm install -g bower$ su - wlsuser$ bower help$ vim .bowerrc{ "registry": "http://:5678" }$ cd $ bower install jquery
有用命令
删除库
使用 POST 方式发送json到 removePackage 路径
bower-server:5678/removePackage { "name": "package-name" }
清除本地bower缓存
$ bower cache clean