rhinoceros.xn edited this page Sep 15, 2018 · 23 revisions

Dependencies

  • Node >= 6.11.3
  • MySQL >= 0.5.0, include mysqld and mysql cli
  • Simple File Store Service, like qiniu, aliyun-oss, tfs, upyun

Deploy With NPM Module [not recommend]

Deploy From Source Code [recommend]

Get the Code

# clone from github
$ git clone git://github.com/cnpm/cnpmjs.org.git $HOME/cnpmjs.org
$ cd $HOME/cnpmjs.org

# create mysql tables
$ mysql -u yourname -p
mysql> create database cnpmjs
mysql> use cnpmjs;
mysql> source docs/db.sql

Edit Your Own Config File

Replace qiniu CDN with Your Own CDN System
$ vim config/config.js
 module.exports = {
    debug: false,
    enableCluster: true, // enable cluster mode
    enablePrivate: true, // enable private mode, only admin can publish, other use just can sync package from source npm
    database: {
		db: 'cnpmjstest',
        host: 'localhost',
        port: 3306,unknown database cnpmjs
        username: 'cnpmjs',
        password: 'cnpmjs123'  
    },
    admins: {
      admin: 'admin@cnpmjs.org',
    },
    syncModel: 'exist'// 'none', 'all', 'exist'
  };  

Install Dependencies

$  npm install --build-from-source --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/mirrors/node

Run

$ npm run start

Check

#open registry and web
# registry
open http://localhost:7001
# web
open http://localhost:7002

Replace qiniu CDN with Your Own CDN System

See an example with oss: oss-cnpm

Use oss-cnpm:

$ cd $HOME/cnpmjs.org
$ cnpm install oss-cnpm
  • Then edit the config/index.js, add nfs options:
nfs: require('oss-cnpm').create({
    accessKeyId: 'YOUR_OSS_AccessKeyID',
    accessKeySecret: 'YOUR_OSS_AccessKeySecret:',
    endpoint: 'YOUR_OSS_Endpoint',
    bucket: 'YOUR_OSS_Bucket',
    mode: 'private',
  }),
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.