NPM 사복 구축
7594 단어 Linux 운영
인터넷 문서에 사용된 NodeJS와 CNPM 버전이 너무 오래되었기 때문에GitHub 홈페이지를 포함하여 다소 문제가 있었고 최종적으로 고생과 정리를 거쳐 이 문서를 형성했다. 문서에서 데이터베이스에 MySQL을 선택하고 Nginx 에이전트를 설치하는 것은 필수적이지 않다.
1. NodeJS 설치
mkdir -p /App/src
cd /App/src
wget https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.xz
tar Jxf node-v6.4.0-linux-x64.tar.xz
mv node-v6.4.0-linux-x64 /App/node
useradd node
echo 'export PATH=/App/node/bin:$PATH' >> /home/node/.bash_profile
2. CNPM 서버 설치
su - node
git clone https://github.com/cnpm/cnpmjs.org.git
cd cnpmjs.org/
npm install
3. MySQL 데이터베이스 만들기 및 권한 부여
CREATE DATABASE cnpmjs;
GRANT ALL ON cnpmjs.* ON cnpmjs@'127.0.0.1' IDENTIFIED BY 'Password';
FLUSH PRIVILEGES;
4. 데이터베이스 가져오기 데이터
mysql -uroot cnpmjs < docs/db.sql
5. 프로필 수정
config/index.js
enableCluster: true,
registryPort
등록 서비스 포트, webPort
웹 액세스 포트, 기본값registryPort: 7001,
webPort: 7002,
admin: '[email protected]',
db: 'cnpmjs',
username: 'cnpmjs',
password: 'Password',
dialect: 'mysql',
host: '127.0.0.1',
port: 3306,
//
를 추가해서 이 줄을 주석합니다.또한 Nginx를 기본 프레임에 리버스 에이전트로 설치할 수 있으므로 이 행을 수정할 필요가 없습니다.bindingHost: '127.0.0.1',
registryHost: 'npm.songsong.org',
enablePrivate: true,
scopes: [ '@songsong.org' ],
sourceNpmRegistry: 'https://registry.npm.taobao.org',
none
동기화되지 않고 원본 공유 모듈만 대리한다.exist
이미 존재하는 모듈만 동기화하기;all
모든 모듈을 동기화합니다.syncModel: 'exist',
6. CNPM 서비스 시작
bin/nodejsctl start
7. Nginx 역방향 에이전트를 추가하고 두 개의 도메인 이름으로 CNPM 웹 서비스와 등록 서비스를 구분하고 설정을 다시 불러옵니다
upstream npm.songsong.org
{
server 127.0.0.1:7002 weight=10;
}
server
{
listen 80;
server_name npm.songsong.org;
index index.html;
location /
{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_pass http://songsong.org;
}
}
upstream reg.songsong.org
{
server 127.0.0.1:7001 weight=10;
}
server
{
listen 80;
server_name reg.songsong.org;
index index.html;
location /
{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_pass http://reg.songsong.org;
}
}
8. CNPM 클라이언트 설치
npm install -g cnpm
9. CNPM 클라이언트 액세스 사복을 설정합니다. 두 가지 방법이 똑같습니다.
cnpm set registry http://reg.songsong.org
~/.cnpmrc
registry=http://reg.songsong.org
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Centos에서 사용 가능한 주종 동기화 DNS 서비스 배치일상적인 업무에서 네트워크 도메인 이름 해석 문제를 해결하기 위해 시간은 DNS 서비스를 설정하여 해석을 제공한다.이때 DNS 서비스는 모든 내부 서비스에 연결을 제공하는 기초를 닦았고 매우 중요하게 변했다.따라서 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.