<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 前言 基于前面的了解或者公司內部的剛需,可能搭建cnpm倉庫已經變成了你必須會的知識點。跟著我一起去服務器部署一個私有的cnpm倉庫吧。 ### 環境要求 * 系統要求:mac或者linux(服務器基本都是linux的) * nodejs:4.2.3 以上版本 ### 基本安裝 * nodejs ~~~ curl -sL https://rpm.nodesource.com/setup_7.x | bash - (腳本) yum install -y nodejs yum install -y gcc-c++ make ~~~ * 安裝mysql 1. 檢測并卸載已有的 ~~~ rpm -qa | grep mariadb rpm -e --nodeps mariadb/mysql ~~~ 2. 安裝mysql-server 2.1 在/etc/yum.repos.d/目錄創建MariaDB.repo文件,內容如下: ~~~ # MariaDB 5.5 CentOS repository list - created 2014-03-04 11:20 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 ~~~ 2.2 安裝對應包 ~~~ sudo yum -y install mariadb-server MariaDB-client ~~~ 2.3 啟動服務 ~~~ //如果你是centos 系統 systemctl start mariadb.service //如果你是GUN/linux ,只有service服務 service mysql start //修改數據庫密碼,默認是空的 mysqladmin -u root password "passwd" ~~~ 2.4 相關命令的拓展 ~~~ //centos 系統 systemctl start mariadb #啟動服務 systemctl enable mariadb #設置開機啟動 systemctl restart mariadb #重新啟動 systemctl stop mariadb.service #停止MariaDB // gun service xxxx start/stop/enable/restart ~~~ * 安裝git并檢出cnpmjs項目 ~~~ //安裝git 下載cnpmjs的git項目 yum install git git clone git://github.com/fengmk2/cnpmjs.org.git $HOME/cnpmjs.org cd cnpmjs.org //用戶登陸 修改相關的庫表信息 Mysql -u root -p create database cnpmjs; use cnpmjs; source docs/db.sql【db.sql位于cnpmjs.org/docs/db.sql】 //允許外部鏈接數據庫(如果 你想查看數據庫的情況有必要設置) grant all privileges on *.* to root@'%' identified by 'password'; //根據自己的需要修改index的配置文件 vim config/index.js ~~~ ### 使用須知 * cnpm提供兩個端口:7001和7002,其中7001用于NPM的注冊服務,7002用于Web訪問。 * bindingHost為安裝cnpm的服務器ip地址,也就是在瀏覽器中只能通過訪問http://192.168.0.234來訪問cnpm以及獲取npm的注冊服務。 修改本地下載地址(registryHost:r.cnpmjs.org修改為192.168.0.129:7001) * 安裝依賴 ~~~ //持久使用 npm config set registry https://registry.npm.taobao.org // 配置后可通過下面方式來驗證是否成功 npm config get registry// 或 npm info express //進入./cnpmjs.org,執行npm install npm install ~~~ * 啟動服務 node dispatch.js或者“nohup node dispatch.js &”來啟動。 其中nohup為在后臺啟動。 ~~~ npm run dev:調試模式啟動; npm run test:跑測試; npm run start:啟動 CNPM;永久的熱啟動 npm run status:查看 CNPM 啟動狀態; npm run stop:停止 CNPM。 ~~~ * 如果啟動時報錯:`/lib64/libc.so.6: version `GLIBC_2.14' not found`,這個是因為glibc版本過低引起的,你可以通過命令查看目前支持的版本:`strings /lib64/libc.so.6 |grep GLIBC ` ,解決辦法從官網下載相關的壓縮包然后編譯安裝,再配置到相關的目錄下。 1. 找到官網:http://www.gnu.org/software/libc/,下載2.14版本后綴為gz的壓縮包,我們下載后放到root/software 下 2. 剩下的都是命令行操作 ~~~cmd //解壓 [root@jrgc130 ~]#tar zxf glibc-2.14.tar.gz [root@jrgc130 ~]# cd /opt/software [root@jrgc130 software]# tar xf glibc-2.14.tar.gz [root@jrgc130 software]# cd glibc-2.14 [root@jrgc130 glibc-2.14]# mkdir build [root@jrgc130 glibc-2.14]# cd build //修改配置文件 [root@jrgc130 build]# ../configure --prefix=/usr/local/glibc-2.14 //安裝 [root@jrgc130 build]# make -j4 [root@jrgc130 build]# make install //拷貝鏈接庫 [root@jrgc130 build]# cd /usr/local/glibc-2.14/lib [root@jrgc130 lib]# cp libc-2.16.so /lib64/ //創建鏈接 [root@jrgc130 lib]# cd /lib64 [root@jrgc130 lib64]# rm -rf libc.so.6 //復制相關文件到so [root@example lib64]# /sbin/sln libc-2.14.so /lib64/libc.so.6 //運行strings /lib64/libc.so.6 |grep GLIBC 可以查看最新支持版本為2.14,問題解決。 ~~~ * 測試是否啟動成功 ~~~ 在瀏覽器中輸入:http://192.168.0.234:7002/,如果出現: 發布私有包 npm config set registry https://registry.npm.taobao.org 安裝cnpm客戶端 curl -sL https://rpm.nodesource.com/setup_7.x | bash - (腳本) yum install -y nodejs sudo npm install cnpm -g 更改默認的registry,指向私有的registry cnpm set registry http://192.168.0.234:7001 ~~~ * 用npm賬號登錄你的私有registry 這里的賬號中www.npmjs.com的賬號,沒有請注冊(admin登錄) ~~~ $ cnpm login Username: admin Password: npm0816@zjkj.com Email: (this IS public) admin@cnpmjs.org ~~~ * 如果過程中遇到不能同步或者下載自己的模塊 ,可以修改/config/index.js 文件 > enableAbbreviatedMetadata: true ### 創建私有測試包 * 生成測試包 ~~~ $ cd /tmp $ mkdir helloworld && cd helloworld $ cnpm init name: @cjt/helloworld version: 1.0.0 ~~~ * 生成package.json(產出文件) : ~~~ { "name": "@cjt/helloworld", "version": "1.0.0", "description": "my first scoped package", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" } ~~~ * 注意事項 1. 注意,包名helloworld前必須要以公司名@cjt為前綴, @cjt在 config/index.js的scopes中配置 ~~~ // registry scopes, if don't set, means do not support scopes,你可以設置為kkl scopes: [ '@cjt','@cnpm', '@cnpmtest', '@cnpm-test' ], ~~~ 2. 其余管理員賬號權限分配必須二次開發,修改 `middleware/publishable.js` ,也可以直接修改index.js中的文件,默認的管理員是admin ; 3. 注冊并登陸用戶: ![](https://box.kancloud.cn/e9017ceb4f238cd5f8eb08e9318ef03e_427x204.png) 3. 發布與同步(見cnpm入門) ~~~ 發布 cnpm publish 通過瀏覽器訪問:http://192.168.0.129:7002/?可查看和操作私有CNPM服務器 從默認源同步gulp cnpm sync gulp 下載 cnpm install gulp ~~~ ## 配置文件(config/index.js)  ~~~ 'use strict'; var mkdirp = require('mkdirp'); var copy = require('copy-to'); var path = require('path'); var fs = require('fs'); var os = require('os'); var version = require('../package.json').version; var root = path.dirname(__dirname); var dataDir = path.join(process.env.HOME || root, '.cnpmjs.org'); var config = { version: version, dataDir: dataDir, /** * Cluster mode 是否啟用?cluster-worker?模式啟動服務,默認?false,生產環節推薦為?true; 利用多核 */ enableCluster: true, numCPUs: os.cpus().length, /* * server configure 服務器的基本設置,ip以及請求以及訪問端口(必須設置) */ registryPort: 7001, webPort: 7002, bindingHost: '10.0.0.141', // only binding on 127.0.0.1 for local access // debug mode // if in debug mode, some middleware like limit wont load // logger module will print to stdout debug: process.env.NODE_ENV === 'development', // page mode, enable on development env pagemock: process.env.NODE_ENV === 'development', // session secret sessionSecret: 'cnpmjs.org test session secret', // max request json body size jsonLimit: '10mb', // log dir name logdir: path.join(dataDir, 'logs'), // update file template dir uploadDir: path.join(dataDir, 'downloads'), // web page viewCache viewCache: false, // config for koa-limit middleware // for limit download rates limit: { enable: false, token: 'koa-limit:download', limit: 1000, interval: 1000 * 60 * 60 * 24, whiteList: [], blackList: [], message: 'request frequency limited, any question, please contact fengmk2@gmail.com', }, enableCompress: false, // enable gzip response or not // default system admins,(管理員必須設置為自己清楚的,只有管理員可以刪除模塊,配置需要重啟) admins: { // name: email fengmk2: 'fengmk2@gmail.com', admin: 'admin@cnpmjs.org', dead_horse: 'dead_horse@qq.com', }, // email notification for errors // check https://github.com/andris9/Nodemailer for more informations mail: { enable: false, appname: 'cnpmjs.org', from: 'cnpmjs.org mail sender <adderss@gmail.com>', service: 'gmail', auth: { user: 'address@gmail.com', pass: 'your password' } }, logoURL: 'https://os.alipayobjects.com/rmsportal/oygxuIUkkrRccUz.jpg', // cnpm logo image url adBanner: '', customReadmeFile: '', // you can use your custom readme file instead the cnpm one customFooter: '', // you can add copyright and site total script html here npmClientName: 'cnpm', // use `${name} install package`,(默認的安裝命令符號) packagePageContributorSearch: true, // package page contributor link to search, default is true // max handle number of package.json `dependencies` property maxDependencies: 200, // backup filepath prefix backupFilePrefix: '/cnpm/backup/', /** * database config(數據庫配置文件,必須設置的) */ database: { db: 'cnpmjs', username: 'root', password: 'kkl123456', // the sql dialect of the database // - currently supported: 'mysql', 'sqlite', 'postgres', 'mariadb' dialect: 'mariadb', // custom host; default: 127.0.0.1 host: '127.0.0.1', // custom port; default: 3306 port: 3306, // use pooling in order to reduce db connection overload and to increase speed // currently only for mysql and postgresql (since v1.5.0) pool: { maxConnections: 10, minConnections: 0, maxIdleTime: 30000 }, // the storage engine for 'sqlite' // default store into ~/.cnpmjs.org/data.sqlite storage: path.join(dataDir, 'data.sqlite'), logging: !!process.env.SQL_DEBUG, }, // package tarball store in local filesystem by default(文件系統,可以默認,可以用其他云服務器) nfs: require('fs-cnpm')({ dir: path.join(dataDir, 'nfs') }), // if set true, will 302 redirect to `nfs.url(dist.key)` downloadRedirectToNFS: false, // registry url name(模塊下載請求地址,必須設置) registryHost: '10.0.0.141:7001', /** * registry mode config */ // enable private mode or not(必須設置,false允許其他人發布,否則只有管理員) // private mode: only admins can publish, other users just can sync package from source npm // public mode: all users can publish enablePrivate: false, // registry scopes, if don't set, means do not support scopes(私有模塊前綴,必須設置) scopes: [ '@kkl'], // some registry already have some private packages in global scope // but we want to treat them as scoped private packages, // so you can use this white list. privatePackages: [], /** * sync configs */ // the official npm registry(官方請求地址,一般不用修改) // cnpm wont directly sync from this one // but sometimes will request it for some package infomations // please don't change it if not necessary officialNpmRegistry: 'http://registry.npm.taobao.org', officialNpmReplicate: 'https://replicate.npmjs.com', // sync source, upstream registry(同步模塊的地址,設置為阿里鏡像建議) // If you want to directly sync from official npm's registry // please drop them an email first sourceNpmRegistry: 'http://registry.npm.taobao.org', // upstream registry is base on cnpm/cnpmjs.org or not // if your upstream is official npm registry, please turn it off sourceNpmRegistryIsCNpm: true, // if install return 404, try to sync from source registry(模塊沒有,從遠程更新下載,必須設置) syncByInstall: true, // sync mode select(同步模式,同步已有模塊即可) // none: do not sync any module, proxy all public modules from sourceNpmRegistry // exist: only sync exist modules // all: sync all modules syncModel: 'exist', // 'none', 'all', 'exist' syncConcurrency: 1, // sync interval, default is 10 minutes(10ms同步一次) syncInterval: '10m', // sync polular modules, default to false(不同步熱門模塊) // because cnpm can't auto sync tag change for now // so we want to sync popular modules to ensure their tags syncPopular: false, syncPopularInterval: '1h', // top 100 topPopular: 100, // sync devDependencies or not, default is false syncDevDependencies: false, // changes streaming sync syncChangesStream: false, handleSyncRegistry: 'http://127.0.0.1:7001', // badge subject on http://shields.io/ badgePrefixURL: 'https://img.shields.io/badge', badgeSubject: 'cnpm', // custom user service, @see https://github.com/cnpm/cnpmjs.org/wiki/Use-Your-Own-User-Authorization // when you not intend to ingegrate with your company's user system, then use null, it would // use the default cnpm user system userService: null, // always-auth https://docs.npmjs.com/misc/config#always-auth // Force npm to always require authentication when accessing the registry, even for GET requests. alwaysAuth: false, // if you're behind firewall, need to request through http proxy, please set this // e.g.: `httpProxy: 'http://proxy.mycompany.com:8080'` httpProxy: null, // snyk.io root url snykUrl: 'https://snyk.io', // https://github.com/cnpm/cnpmjs.org/issues/1149(針對某個補丁文件的修復,必須設置) // if enable this option, must create module_abbreviated and package_readme table in database enableAbbreviatedMetadata: true, // global hook function: function* (envelope) {} // envelope format please see https://github.com/npm/registry/blob/master/docs/hooks/hooks-payload.md#payload globalHook: null, }; if (process.env.NODE_ENV === 'test') { config.enableAbbreviatedMetadata = true; } if (process.env.NODE_ENV !== 'test') { var customConfig; if (process.env.NODE_ENV === 'development') { customConfig = path.join(root, 'config', 'config.js'); } else { // 1. try to load `$dataDir/config.json` first, not exists then goto 2. // 2. load config/config.js, everything in config.js will cover the same key in index.js customConfig = path.join(dataDir, 'config.json'); if (!fs.existsSync(customConfig)) { customConfig = path.join(root, 'config', 'config.js'); } } if (fs.existsSync(customConfig)) { copy(require(customConfig)).override(config); } } mkdirp.sync(config.logdir); mkdirp.sync(config.uploadDir); module.exports = config; config.loadConfig = function (customConfig) { if (!customConfig) { return; } copy(customConfig).override(config); }; ~~~ ### 參考測試文檔 * [cnpm配置](http://blog.csdn.net/xs20691718/article/details/51898164) * [cnpm官網文檔介紹](https://github.com/cnpm/cnpmjs.org/wiki)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看