NPM私有服务器架设 FOR CentOS

确保计算机能够连接互连网。
一、安装 Couchdb1.6
1、(CentOS 6.7)如果版本低于6.7请使用下面命令更新系统库。
yum update
2、使用下面命令安装依赖库
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
3、安装 Erlang 库
代码名称:otp_src_R15B01.tar.gz(注意版本必需大于 R15B01)
下载地址:http://www.erlang.org/download/otp_src_R15B01.tar.gz
执行以下命令:
# tar -xvf otp_src_R14B01.tar.gz 解压

cd otp_src_R14B01 进行目录

./configure 安装解检测

make && make install 编译并安装

4、安装 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.gz

cd mozjs17.0.0/js/src/

./configure

make && make install

5、安装 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

cd mozjs17.0.0/js/src/

./configure

make && make install

6、配置 CouchDb 数据库
# adduser --no-create-home couchdb

chown -R couchdb:couchdb /usr/local/var/lib/couchdb /usr/local/var/log/couchdb /usr/local/var/run/couchdb

ln -sf /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb

chkconfig --add couchdb

chkconfig couchdb on

7、设置 IP 和 端口
# vi /usr/local/etc/couchdb/local.ini

[httpd]
port = 5984
bind_address = 192.168.0.128
8、启动与停止
启动 :# /etc/init.d/couchdb start
查看状态:# /etc/init.d/couchdb status
停止:#/etc/init.d/couchdb stop
9、访问数据库
http://192.168.0.128:5984/_utils

10、添加用户
打开管理画面:http://x.x.x.x:5984/_utils/ 
点击画面右下角的“Fix this”,创建用户。admin/admin

二、架设NPM 私有服务器
1、创建数据库
[root@npm_private ~]# curl -X PUT http://admin:admin@ipaddress:5984/registry
{“ok”:true}
2、配置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

3、安装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
4、安装 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/_rewrite

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 test

posted @ 2015-12-04 16:02  吴碧宇  阅读(1113)  评论(0编辑  收藏  举报