CNMP私庫的搭建
1. 環境準備
Linux:centos6.5
Node:v8.9.4
Npm:5.6.0
Mysql:5.6.17
Ip:192.168.1.203
2. 安裝mysql(本次編譯安裝)
將mysql源碼包copy到服務器root目錄下,執行以下步驟;
rpm -qa | grep mysql
rpm -e mysql
yum groupinstall -y "Development Tools" "Server Platform Development"
yum -y install make gcc-c++ cmake bison-devel ncurses-devel wget vim
yum -y install gcc gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
yum -y install bison unzip
groupadd mysql && useradd -g mysql mysql
tar xf mysql-5.6.17.tar.gz
cd mysql-5.6.17
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
mv /etc/my.cnf{,.bak}
cp support-files/mysql.server /etc/rc.d/init.d/mysql
chkconfig mysql on
/etc/init.d/mysql start
3. 安裝node
1) 安裝依賴關系;
yum install libicu-devel openssl-devel curl-devel make gcc erlang js-devel libtool which gcc-c++ vim git
2) 解壓node源碼包編譯安裝;
tar xf node-v8.9.4.tar.gz
cd node-v8.9.4
./configure
make
make install
Note:
a. 執行./configure操作時會報以下錯誤,需要先升級gcc至高版本,再繼續執行(升級過程見補充);
b. 執行make出現以下錯誤;
解決方法:
3) 安裝完可驗證;
4. 搭建cnpm;
1) Github獲取代碼並進入目錄;
2) 安裝依賴;
3) 創建mysql數據庫
4) 授權數據用戶並驗證;
5) 更改cnpm項目配置文件;
Note:enableAbbreviatedMetadata需要設為true,不然會出現以下錯誤
6) 啟動cnpm服務;
Nohup node --harmony dispatch.js & (後臺運行)
7) 瀏覽器測試;(7002端口提供web服務,7001提供npm註冊服務)
8) 添加管理員
npm adduser --registry=http://192.168.1.203:7001
Username: admin
Password: (自己寫)
Email: (this IS public) 必須為上面配置的郵箱,即[email protected]
補充:升級gcc過程;
1) 解壓源碼包
tar xf gcc-4.9.4.tar.bz2
2) 下載編譯所需依賴庫;
./contrib/download_prerequisites
3) 編譯安裝;
. /configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Make && make install
CNMP私庫的搭建