CentOS安裝NodeJS及Express開發架構

來源:互聯網
上載者:User
本文示範在Linux上安裝NodeJS及Express開發架構
軟體環境: VMware 9 CentOS 6.5 NodeJS v0.10.24
安裝過程: Step 1、確認伺服器有nodejs編譯及依賴相關軟體,如果沒有可通過運行以下命令安裝。

[root@BobServerStation local]# yum -y install gcc gcc-c++ openssl-devel
Step 2、下載NodeJS源碼包並解壓。

[root@BobServerStation local]# wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz [root@BobServerStation local]# tar zxvf  node-v0.10.24.tar.gz [root@BobServerStation local]# c d node-v0.10.24
Step 3、配置、編譯、安裝。

[root@BobServerStation node-v0.10.24]# ./configure --prefix=/usr/local/node [root@BobServerStation node-v0.10.24]# make && make install 將持續3-4min....
Step 4、接下來配置Node環境

[root@BobServerStation node-v0.10.24]# vim /etc/profile


#set nodejs env export NODE_HOME=/usr/local/node export PATH=$NODE_HOME/bin:$PATH export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH
[root@BobServerStation node-v0.10.24 ]#  source /etc/profile        --重啟生效
Step 5、測試是否安裝成功

[root@BobServerStation node-v0.10.24]# node -v

v0.10.24 出現NodeJS版本號碼則表示OK。
Step 6、NodeJS之Hello World

[root@BobServerStation node-v0.10.24]# node

> console.log(”Hello NodeJS, I'm Bob.Z“);

Hello NodeJS, I'm Bob.Z

undefined

>  輸出:Hello NodeJS, I'm Bob.Z
Step 7、安裝Express開發架構

[root@BobServerStation local]# npm install express -g
Step 8、建立Demo項目

[root@BobServerStation local]# express DemoApp

[root@BobServerStation local]# cd DemoApp

[root@BobServerStation DemoApp]# 
Step 9、進入項目目錄並安裝項目相依元件

[root@BobServerStation local]# cd DemoApp

[root@BobServerStation DemoApp]# npm install
Step 10、相依元件安裝完成後啟動app

[root@BobServerStation DemoApp]# node app

Express server listening on port 3000
最後通過瀏覽器訪問伺服器3000連接埠,頁面顯示, Express

Welcome to Express

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.