最近公司服務(wù)器因?yàn)槟承┰蚩呛浚瑢?dǎo)致服務(wù)器環(huán)境需要全部重新部署规求,安裝nodejs又忘了稿壁,記錄下实束,方便下次使用奥秆。
安裝最新版nodejs
更新ubuntu軟件源
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
安裝nodejs
sudo apt-get install nodejs
更新npm的包鏡像源,方便快速下載
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
全局安裝n管理器(用于管理nodejs版本)
sudo npm install n -g
安裝最新的nodejs(stable版本)
sudo n stable
sudo node -v
QA
Q: 更新軟件源出現(xiàn)-找不到對應(yīng)的KEY
// error code
W: There is no public key available for the following key IDs:
8B48AD6246925553
W: Failed to fetch http://mirrors.aliyuncs.com/ubuntu/dists/precise/Release.gpg Could not connect to mirrors.aliyuncs.com:80 (10.143.34.200), connection timed out
// A:resolve: add key
gpg --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
gpg -a --export 8B48AD6246925553 | sudo apt-key add -
Q: aliyun咸灿、163等其他軟件源一直出現(xiàn)下載失敗
// error code
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise/Release.gpg Could not connect to mirrors.163.com:80 (123.58.173.106). - connect (111: Connection refused)
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-security/Release.gpg Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-updates/Release.gpg Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-proposed/Release.gpg Unable to connect to mirrors.163.com:http:
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/precise-backports/Release.gpg Unable to connect to mirrors.163.com:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.
// A: 部分網(wǎng)絡(luò)問題构订,下載失敗,嘗試換成官方源避矢,雖然比較慢悼瘾,但是能下載
// resolve:修改apt文件 /etc/apt/sources.list(注意備份)
# Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
Q: sudo make編譯nodejs失敗
make[1]: *** [/home/software/node-v7.8.0/out/Release/obj.target/v8_libplatform/deps/v8/src/libplatform/default-platform.o] Error 1
make[1]: Leaving directory `/home/software/node-v7.8.0/out'
make: *** [node] Error 2
// A: gcc版本太低囊榜,需要把gcc升級到4.8以上
ubuntu軟件源
修改/etc/apt/sources.list為以下軟件源(改前請備份)
163和里面在部分網(wǎng)絡(luò)下會一直下載失敗,可以改回官方源下載
源列表
http://wiki.ubuntu.org.cn/模板:14.04source
Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
163軟件源
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
aliyun軟件源
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ precise-backports main restricted universe multiverse