① 如何在CentOS 7伺服器上安裝NodeJS
你可以通過運行以下命令。
sudo yum install epel-release
現在可以使用yum命令安裝Node.js了。
sudo yum install nodejs
因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟體包管理器,使用以下命令。
sudo yum install npm
② 如何在CentOS 7伺服器上安裝NodeJS
你可以通過運行以下命令。
1
sudo yum install epel-release
現在可以使用yum命令安裝Node.js了。
1
sudo yum install nodejs
因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟體包管理器,使用以下命令。
1
sudo yum install npm
③ 如何在64位的CentOS6.4上安裝及運行NodeJS應用
1、如果對nodejs環境有比較高的要求,建議選擇源碼安裝的方式進行安裝。
你可以到nodejs org官網上面找到相對的tar.gz文件包。
通過wget命令下載到centos伺服器上, 然後進行源碼安裝。
2、如果對版本要求不高,可以直接用centos的包管理器yum進行安裝
yum install nodejs npm
3、nodejs版本也可以通過nvm等工具去控制,期待深入研究。
④ 如何在centos下部署Node環境
下載並安裝 Node.js
下載最新的穩定版 v6.10.3 到本地
wget https://nodejs.org/dist/v6.10.3/node-v6.10.3-linux-x64.tar.xz
下載完成後, 將其解壓
tar xvJf node-v6.10.3-linux-x64.tar.xz
將解壓的 Node.js 目錄移動到 /usr/local 目錄下
mv node-v6.10.3-linux-x64 /usr/local/node-v6
配置 node 軟鏈接到 /bin 目錄
ln -s /usr/local/node-v6/bin/node /bin/node
配置和使用 npm
配置 npm
npm 是 Node.js 的包管理和分發工具。它可以讓 Node.js 開發者能夠更加輕松的共享代碼和共用代碼片段
下載 node 的壓縮包中已經包含了 npm , 我們只需要將其軟鏈接到 bin 目錄下即可
ln -s /usr/local/node-v6/bin/npm /bin/npm
配置環境變數
將 /usr/local/node-v6/bin 目錄添加到 $PATH 環境變數中可以方便地使用通過 npm 全局安裝的第三方工具
echo 'export PATH=/usr/local/node-v6/bin:$PATH' >> /etc/profile
生效環境變數
source /etc/profile
通過 npm 安裝進程管理模塊 forever
npm install forever -g
⑤ 如何在centos6上部署nodejs服務
1.首先你要有一台伺服器:
系統:Linux (本人選用的是centos6,其它機器不成功不要怪我)
配置需求:至少是256M內存,(前輩們的血淚經驗)
其它:隨意
2.操作流程:
1,安裝vncviewer遠程可視化桌面(或者跳過這步,用FileZilla傳文件什麼的)2,安裝nodejs環境3,安裝mongodb3.24,安裝git(可以不安裝)
3.安裝vncviewer桌面:
本地的直接下載客戶端,支持所有電腦系統和手機端
使用putty鏈接遠程伺服器,然後執行以下安裝腳本,
服務端一鍵安裝腳本如下(看得懂的可以另行修改):
[VNC安裝教程][1] https://segmentfault.com/a/1190000009666125
如果安裝斷開沒關系,重新輸入腳本,會繼續安裝,
安裝成功後會提示輸入兩次密碼,**記住這里的密碼**
4.安裝nodejs環境:
第1步 – 添加Node.js的Yum庫
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
第2步 – 安裝Node.js和NPM
yum install nodejs
第3步 – 檢查Node.js和NPM版本
$ node -vv6.2.0$ npm -v3.8.9
5.安裝mongodb資料庫
注意:這里需要一些Linux和VIM命令操作,不懂的可以谷歌Linux vim
*在終端執行* vi /etc/yum.repos.d/mongodb-org-3.2.repo 命令(創建或打開該文件)*在mongodb-org-3.2.repo中輸入*[mongodb-org-3.2] name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.2/x86_64/ gpgcheck=0
enabled=1
*用yum安裝mongodb(如果沒有寫repo文件則不能用yum安裝)*
sudo yum install -y mongodb-org*啟動mongodb服務*
sudo service mongod start
6.安裝git
yum -y install zlib-devel curl-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib autoconf tk perl-ExtUtils-MakeMaker
獲取最新版 Git 源碼包
從 https://github.com/git/git/releases 下載最新版的 zip 包或者 tar.gz 並解壓:
以 tar.gz 格式為例(在網頁的 tar.gz 上右鍵復制下載鏈接即可):
wget https://github.com/git/git/archive/v2.4.0.tar.gz
tar zxvf v2.4.0.tar.gz
會得到一個 git-2.4.0 的目錄(版本號與下載的一致),然後進入這個目錄:cd git-2.4.0 編譯安裝
autoconf
./configuremakemake install
以上4步請一步步來,以免出現錯誤不好找原因。
然後修改 /etc/ld.so.conf 文件,在最後加入一行:
/usr/local/lib
保存並關閉。
這就安裝好了,看看版本:
git --versiongit version 2.4.0如果安裝後報以下錯誤:
bash: /usr/bin/git: 沒有那個文件或目錄
那麼請編輯 /etc/profile 在最後加入一行:
export PATH=$PATH:/usr/local/bin
然後重新開窗口就好了,或者執行命令 source /etc/profile 後就好了。
⑥ 如何在CentOS 7伺服器上安裝NodeJS
你可以通過運行以下命令。
1
sudo yum install epel-release
現在可以使用yum命令安裝Node.js了。
1
sudo yum install nodejs
因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟體包管理器,使用以下命令。
1
sudo yum install npm
望採納
⑦ 如何在CentOS 7伺服器上安裝NodeJS
Introction
Node.js is a Javascript platform for server-side programming. It
allows users to easily create networked applications that require
backend functionality. By using Javascript as both the client and server
language, development can be fast and consistent.
In this guide, we will show you a few different ways of getting
Node.js installed on a CentOS 7 server so that you can get started. Most
users will want to use the EPEL installation instructions or the NVM
installation steps.
Install Node from Source
One way of acquiring Node.js is to obtain the source code and compile it yourself.
To do so, you should grab the source code from the project』s website.
On the downloads page, right click on the 「Source Code」 link and click
「Copy link address」 or whatever similar option your browser gives you.
On your server, use wget and paste the link that you copied in order to download the archive file:
wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz
Extract the archive and move into the new directory by typing:
tar xzvf node-v* && cd node-v*
There are a few packages that we need to download from the CentOS
repositories in order to compile the code. Use yum to get these now:
sudo yum install gcc gcc-c++
Now, we can configure and compile the software:
./configure
make
The compilation will take quite awhile. When it is finished, you can install the software onto your system by typing:
sudo make install
To check that the installation was successful, you can ask Node to display its version number:
node –version
v0.10.30
If you see the version number, then the installation was completed successfully.
Install a Package from the Node Site
Another option for installing Node.js on your server is to simply get
the pre-built packages from the Node.js website and install them.
You can find the Linux binary packages here. Since CentOS 7 only
comes in the 64-bit architecture, right click on the link under 「Linux
Binaries (.tar.gz)」 labeled 「64-bit」. Select 「Copy link address」 or
whatever similar option your browser provides.
On your server, change to your home directory and use the wget
utility to download the files. Paste the URL you just copied as the
argument for the command:
cd ~
wget http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz
Note: Your version number in the URL is likely to be different than
the one above. Use the address you copied from the Node.js site rather
than the specific URL provided in this guide.
Next, we will extract the binary package into our system』s local
package hierarchy with the tar command. The archive is packaged within a
versioned directory, which we can get rid of by passing the
–strip-components 1 option. We will specify the target directory of our
command with the -C command:
sudo tar –strip-components 1 -xzvf node-v* -C /usr/local
This will install all of the components within the /usr/local branch of your system.
You can verify that the installation was successful by asking Node for its version number:
node –version
v0.10.30
The installation was successful and you can now begin using Node.js on your CentOS 7 server.
Install Node from the EPEL Repository
An alternative installation method uses the EPEL (Extra Packages for
Enterprise Linux) repository that is available for CentOS and related
distributions.
To gain access to the EPEL repo, you must modify the repo-list of
your installation. Fortunately, we can reconfigure access to this
repository by installing a package available in our current repos called
epel-release.
sudo yum install epel-release
Now that you have access to the EPEL repository, you can install Node.js using your regular yum commands:
sudo yum install nodejs
Once again, you can check that the installation was successful by asking Node to return its version number:
node –version
v0.10.30
Many people will also want access to npm to manage their Node packages. You can also get this from EPEL by typing:
sudo yum install npm
Install Node Using the Node Version Manager
Another way of installing Node.js that is particularly flexible is
through NVM, the Node version manager. This piece of software allows you
to install and maintain many different independent versions of Node.js,
and their associated Node packages, at the same time.
To install NVM on your CentOS 7 machine, visit the project』s GitHub
page. Copy the curl or wget command from the README file that displays
on the main page. This will point you towards the most recent version of
the installation script.
Before piping the command through to bash, it is always a good idea
to audit the script to make sure it isn』t doing anything you don』t agree
with. You can do that by removing the | bash segment at the end of the
curl command:
curl https//raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh
Take a look and make sure you are comfortable with the changes it is
making. When you are satisfied, run the command again with | bash
appended at the end. The URL you use will change depending on the latest
version of NVM, but as of right now, the script can be downloaded and
executed by typing:
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
This will install the nvm script to your user account. To use it, you must first source your .bash_profile:
source ~/.bash_profile
Now, you can ask NVM which versions of Node it knows about:
nvm list-remote
. . .
v0.10.29
v0.10.30
v0.11.0
v0.11.1
v0.11.2
v0.11.3
v0.11.4
v0.11.5
v0.11.6
v0.11.7
v0.11.8
v0.11.9
v0.11.10
v0.11.11
v0.11.12
v0.11.13
You can install a version of Node by typing any of the releases you see. For instance, to get version 0.10.30, you can type:
nvm install v0.10.30
You can see the different versions you have installed by typing:
nvm list
-> v0.10.30
system
You can switch between them by typing:
nvm use v0.10.30
Now using node v0.10.30
To set this version as the default, type:
nvm alias default v0.10.30
default -> v0.10.30
You can verify that the install was successful using the same technique from the other sections, by typing:
node –version
v0.10.30
From the version number output, we can tell that Node is installed on our machine as we expected.
Conclusion
As you can see, there are quite a few different ways of getting
Node.js up and running on your CentOS 7 server. If one of the
installation methods is giving you problems, try one of the other
options.
⑧ 如何在CentOS 7伺服器上安裝NodeJS
你可以通過運行以下命令。
1
sudo yum install epel-release
現在可以使用yum命令安裝Node.js了。
1
sudo yum install nodejs
因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟體包管理器,使用以下命令。
1
sudo yum install npm
⑨ 如何在CentOS 7伺服器上安裝NodeJS
你可以通過運行以下命令。 1 sudo yum install epel-release 現在可以使用yum命令安裝Node.js了。 1 sudo yum install nodejs 因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟體包管理器,使用以下命令。 1 sudo yum install npm
⑩ 如何在CentOS/RHEL 7/6/上安裝最新的Nodej和NPM
Node.js是一個建立在Chrome的JavaScript運行時的平台,用於輕松構建快速,可擴展的網路應用程序。 最新版本的node.js yum存儲庫由其官方網站維護。 我們可以將此yum存儲庫添加到我們的CentOS/RHEL 7/6系統中,並使用簡單的命令安裝node.js。
添加Node.js yum源
首先我們將在nodejs官方網站提供的系統中添加node.js yum庫。您還需要開發工具來構建要在系統上安裝的本機插件。
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
安裝Node.js 和NPM
在您的系統中添加yum存儲庫後,可以安裝Nodejs軟體包。 NPM也將與node.js.一起安裝。此命令還將在系統上安裝許多其他相關軟體包。
yum erase nodejs npm -y # 卸載舊版本的nodejsrpm -qa 'node|npm' | grep -v nodesource # 確認nodejs是否卸載干凈yum install nodejs -y
檢查Node.js和NPM版本
node -vnpm -v
創建演示Web伺服器
這是一個可選的步驟。如果你想測試你的node.js安裝。讓我們創建一個帶有「Welcome Node.js」文本的Web伺服器。創建一個文件demo_server.js
vim demo_server.jsvar http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Welcome Node.js');
}).listen(3001, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3001/');
現在使用以下命令啟動Web伺服器,建議把127.0.0.1改為本機ip
node --debug demo_server.js
Web伺服器已經在埠3001上啟動。現在在瀏覽器中訪問http://127.0.0.1:3001/url