確保計算機可以鏈接互連網。
1、安裝 Couchdb1.6
一、(CentOS 6.7)若是版本低於6.7請使用下面命令更新系統庫。
yum update
二、使用下面命令安裝依賴庫
yum install autoconf autoconf autoconf-archive automake ncurses-devel curl-devel erlang-asn1 erlang-erts erlang-eunit erlang-os_mon erlang-xmerl help2man js-devel libicu-devel libtool perl-Test-Harness
三、安裝 Erlang 庫
代碼名稱:otp_src_R15B01.tar.gz(注意版本必需大於 R15B01)
下載地址:http://www.erlang.org/download/otp_src_R15B01.tar.gz
執行如下命令:
# tar -xvf otp_src_R14B01.tar.gz 解壓node
四、安裝 MozillaSpiderMonkey 代碼名稱:mozjs17.0.0.tar.gz 下載地址:http://ftp.mozilla.org/pub/mozilla.org/js/mozjs17.0.0.tar.gz
執行如下命令:
# tar -xvf mozjs17.0.0.tar.gzgit
五、安裝 CouchDb 數據庫 下載地址:http://mirror.tcpdiag.net/apache/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz 執行如下命令: # tar -xvf mozjs17.0.0.tar.gz
六、配置 CouchDb 數據庫 # adduser --no-create-home couchdb
七、設置 IP 和 端口 # vi /usr/local/etc/couchdb/local.ini
[httpd]
port = 5984
bind_address = 192.168.0.128
八、啓動與中止
啓動 :# /etc/init.d/couchdb start
查看狀態:# /etc/init.d/couchdb status
中止:#/etc/init.d/couchdb stop
九、訪問數據庫
http://192.168.0.128:5984/_utilsgithub
十、添加用戶 打開管理畫面:http://x.x.x.x:5984/_utils/ 點擊畫面右下角的「Fix this」,建立用戶。admin/admin
2、架設NPM 私有服務器
一、建立數據庫
[root@npm_private ~]# curl -X PUT http://admin:admin@ipaddress:5984/registry
{「ok」:true}
二、配置npm用數據庫
[root@npm_private ~]# vi /usr/local/etc/couchdb/local.ini
[couch_httpd_auth]
public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
users_db_public = true
[httpd]
secure_rewrites = false
[couchdb]
delayed_commits = false數據庫
三、安裝git和node [root@npm_private ~]# yum install git
[root@npm_private ~]# yum install npm
[root@npm_private ~]# rpm --import https://fedoraproject.org/static/0608B895.txt
[root@npm_private ~]# rpm -Uvh http://download-i2.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@npm_private ~]# yum install nodejs npm --enablerepo=epel
四、安裝 npm-registry-couchapp
[root@npm_private ~]# git clone git://github.com/npm/npm-registry-couchapp
[root@npm_private ~]# cd npm-registry-couchapp/
[root@npm_private npm-registry-couchapp]# npm install
[root@npm_private npm-registry-couchapp]# npm start --npm-registry-couchapp:couch=http://admin:admin@ipaddress:5984/registry
[root@npm_private npm-registry-couchapp]# npm run load --npm-registry-couchapp:couch=http://admin:admin@ipaddress:5984/registry
5. 查找本地.npmrc文件
$ npm config ls -l
...
userconfig = "/xxxxxxx/.npmrc"
...
6.在本地定義.npmrc
registry = http://ipaddress:5984/registry/_design/scratch/_rewriteapache
7. 發佈項目到npm 1. 在官網註冊npm帳號 2. 用戶驗證,命令行執行
npm adduser
3. 發佈模塊,在模塊的根文件夾執行
npm publish
4. 更新版本
npm version 0.0.4
npm publish
若是是git庫時,會爲新版本號建立一條提交信息,package版本號會自動遞增。
5. npm經常使用命令
npm install module_name 模塊安裝
npm -g install module_name 全局安裝
npm search module_name 查找模塊
npm docs module_name 查找模塊文檔
npm install 安裝package.json指定的全部模塊
npm start
npm testnpm