這篇主要是記錄Linux下安裝Node及memcached遇到的問題及安裝配置過程,方便日後查閱
Node安裝及配置
[root@hostname ~]tar zxvf node-v0.12.4.tar.gz
[root@hostname ~]cd node-v0.12.4
[root@hostname ~]./configure --prefix=/usr/local/node
[root@hostname ~]make
[root@hostname ~]make install
[root@hostname ~]cd ..
安裝完後需要配置Node的環境變量
[root@hostname ~]export PATH=/usr/local/node/bin: //關閉終端後再次打開就失效了
[root@hostname ~]vi /etc/profile 在文件末尾添加以下內容
export NODE_HOME=/usr/local/node
export PATH =$PATH:$NODE_HOME/bin
export NODE_PATH =$NODE_HOME/lib/node_modules
[root@hostname ~]source /etc/profile 使修改立即生效
檢查是否安裝成功
[root@hostname ~]node -v
[root@hostname ~]v0.12.4
[root@hostname ~]node
>console.log('installing success')
installing success
undefined
>
一切正常,完成安裝
memcached安裝配置
由於memcached的執行需要依賴於libevent,先安裝libevent(有的Linux系統自帶libevent安裝軟件,考慮到版本問題,建議自行安裝libevent)
[root@hostname ~]tar zxvf libevent-2.0.22-stable.tar.gz
[root@hostname ~]cd libevent-2.0.22-stable
[root@hostname ~]./configure --prefix=/usr
[root@hostname ~]make
[root@hostname ~]make install
安裝memcached
[root@hostname ~]tar xzvf memcached-1.4.24.tar.gz
[root@hostname ~]cd memcached-1.4.24
[root@hostname ~]./configure --with-libevent=/usr
[root@hostname ~]make
[root@hostname ~]make install
安裝完成後啟動memcached
[root@hostname ~]memcached -d -m 2048 -uroot -l 127.0.0.1 -p 11211 -c 256 -P /usr/local/bin/memcached.pid
參數說明:
-d 選項是啟動一個守護進程,
-m 是分配給Memcache使用的內存數量,單位是MB,這裡是2G,
-u 是運行Memcache的用戶,這裡是root,
-l 是監聽的服務器IP地址,如果有多個地址的話,以逗號隔開。這裡指定了localhost,
-p 是設置Memcache監聽的端口,默認11211,最好是1024以上的端口,
-c 選項是最大運行的並發連接數,默認是1024,我這裡設置了256,按照你服務器的負載量來設定,
-P 是設置保存Memcache的pid文件,我這裡是保存在 /usr/local/bin/memcached.pid
檢查memcached是否正確運行,這裡使用telnet命令檢查
[root@hostname ~]telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
到這裡memcached也完成安裝
--------------------------------------------------------------------------------
tips:如果使用telnet命令時提示:command not found ------說明沒有安裝telnet命令,CentOS直接使用yum安裝
[root@hostname ~]yum install telnet
下面關於Node.js的內容你可能也喜歡:
在 Ubuntu 14.04/15.04 上安裝配置 Node.js v4.0.0 http://www.linuxidc.com/Linux/2015-10/123951.htm
如何在CentOS 7安裝Node.js http://www.linuxidc.com/Linux/2015-02/113554.htm
Ubuntu 14.04下搭建Node.js開發環境 http://www.linuxidc.com/Linux/2014-12/110983.htm
Ubunru 12.04 下Node.js開發環境的安裝配置 http://www.linuxidc.com/Linux/2014-05/101418.htm
Node.Js入門[PDF+相關代碼] http://www.linuxidc.com/Linux/2013-06/85462.htm
Node.js開發指南 高清PDF中文版 +源碼 http://www.linuxidc.com/Linux/2014-09/106494.htm
Node.js入門開發指南中文版 http://www.linuxidc.com/Linux/2012-11/73363.htm
Ubuntu 編譯安裝Node.js http://www.linuxidc.com/Linux/2013-10/91321.htm
Node.js 的詳細介紹:請點這裡
Node.js 的下載地址:請點這裡