码迷,mamicode.com
首页 > 其他好文 > 详细

新手玩个人服务器(阿里云)续二

时间:2014-08-30 04:34:38      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:nodejs   centos   express   阿里云   linux   

       小二班一番厮杀:那英四强诞生:大家闺秀,小家碧玉,窈窕淑女,妍姿俊俏 。不解释!?不行!陈冰,李嘉格,刘明湘,张碧晨。大多数的时候,只要脸好看,一切都那么自热而然的顺理成章。虽然网上骂声四起,黑压压一片,总有那么一片不满。忆往昔,快女十强美女寥寥无几,众人云云,不也发出过中性一片,大扫雅兴。

迎合往往活的心力憔悴,从第一届的梁博,张玮,多亮,张赫宣。次奥,我居然还记得,红果果四个汉子,只能佐证那英也喜欢汉子。

          昨晚我仍旧没能装上node,因为报错

Traceback (most recent call last):  
  File "../../tools/js2c.py", line 36, in <module>  
    import bz2  
ImportError: No module named bz2  
make[1]: *** [/home/softs/node-v0.8.12/out/Release/obj/gen/libraries.cc] Error 1  
make[1]: Leaving directory `/home/softs/node-v0.8.12/out'  
make: *** [node] Error 2  
一番折腾,原来装Python的时候,忘记装了bz2
yum -y install bzip2*  
cd /usr/local/src/Python-2.7.5/Modules/zlib
./configure ;  
make;  
make install  
cd /usr/local/src/Python-2.7.5
python setup.py install


然后回到/usr/local/src/node-v0.10.24

cd /usr/local/src/node-v0.10.24

make 

make install

node -v

v0.10.24

node安装成功。


参考: http://flyer2010.iteye.com/blog/1699946

http://hxl2009.blog.51cto.com/779549/1031320

http://blog.csdn.net/liubo2012/article/details/8367603


npm -v
1.3.21

可见node包管理器npm也安装好了。

 node
> console.log("hello Nodejs ");
hello Nodejs
测试成功


接着安装express框架

 npm install express -g

express@4.8.6 /usr/local/lib/node_modules/express
├── merge-descriptors@0.0.2
├── utils-merge@1.0.0
├── cookie@0.1.2
├── escape-html@1.0.1
├── cookie-signature@1.0.4
├── finalhandler@0.1.0
├── range-parser@1.0.0
├── fresh@0.2.2
├── vary@0.1.0
├── media-typer@0.2.0
├── parseurl@1.3.0
├── methods@1.1.0
├── serve-static@1.5.3
├── buffer-crc32@0.2.3
├── path-to-regexp@0.1.3
├── depd@0.4.4
├── qs@2.2.0
├── debug@1.0.4 (ms@0.6.2)
├── proxy-addr@1.0.1 (ipaddr.js@0.1.2)
├── type-is@1.3.2 (mime-types@1.0.2)
├── accepts@1.0.7 (negotiator@0.4.7, mime-types@1.0.2)
└── send@0.8.3 (destroy@1.0.3, ms@0.6.2, mime@1.2.11, on-finished@2.1.0)

突然想起我熟悉3的框架,当前装了最新版4,于是卸载

npm uninstall express

重新装 指定版本

npm install express@3.5.* -g
express@3.5.3 /usr/local/lib/node_modules/express
├── methods@0.1.0
├── merge-descriptors@0.0.2
├── cookie@0.1.2
├── debug@0.8.1
├── cookie-signature@1.0.3
├── fresh@0.2.2
├── range-parser@1.0.0
├── buffer-crc32@0.2.1
├── mkdirp@0.4.0
├── commander@1.3.2 (keypress@0.1.0)
├── send@0.3.0 (debug@0.8.0, mime@1.2.11)
└── connect@2.14.5 (response-time@1.0.0, pause@0.0.1, method-override@1.0.0, connect-timeout@1.0.0, vhost@1.0.0, qs@0.6.6, basic-auth-connect@1.0.0, bytes@0.3.0, raw-body@1.1.4, static-favicon@1.0.2, errorhandler@1.0.0, setimmediate@1.0.1, morgan@1.0.0, csurf@1.1.0, cookie-parser@1.0.1, compression@1.0.0, express-session@1.0.2, serve-static@1.1.0, serve-index@1.0.1, multiparty@2.2.0)


express -V
3.5.3


express3安装成功,

基于该框架建立node平台的web,

进入之前挂载的目录,新建目录web
mkdir web
建立node express web
express MioApp


   create : MioApp
   create : MioApp/package.json
   create : MioApp/app.js
   create : MioApp/public
   create : MioApp/public/javascripts
   create : MioApp/public/images
   create : MioApp/public/stylesheets
   create : MioApp/public/stylesheets/style.css
   create : MioApp/routes
   create : MioApp/routes/index.js
   create : MioApp/routes/user.js
   create : MioApp/views
   create : MioApp/views/layout.jade
   create : MioApp/views/index.jade

   install dependencies:
     $ cd MioApp && npm install

   run the app:
     $ node app

执行上述目录已经在当前目录建立了一个MioApp网站
然后进入MioApp目录
cd MioApp
执行
npm install
加载各种依赖包
express@3.5.3 node_modules/express
├── methods@0.1.0
├── merge-descriptors@0.0.2
├── cookie@0.1.2
├── debug@0.8.1
├── cookie-signature@1.0.3
├── range-parser@1.0.0
├── fresh@0.2.2
├── buffer-crc32@0.2.1
├── mkdirp@0.4.0
├── send@0.3.0 (debug@0.8.0, mime@1.2.11)
├── commander@1.3.2 (keypress@0.1.0)
└── connect@2.14.5 (response-time@1.0.0, pause@0.0.1, method-override@1.0.0, connect-timeout@1.0.0, vhost@1.0.0, qs@0.6.6, basic-auth-connect@1.0.0, bytes@0.3.0, raw-body@1.1.4, static-favicon@1.0.2, errorhandler@1.0.0, setimmediate@1.0.1, serve-static@1.1.0, cookie-parser@1.0.1, compression@1.0.0, morgan@1.0.0, csurf@1.1.0, serve-index@1.0.1, express-session@1.0.2, multiparty@2.2.0)

jade@1.5.0 node_modules/jade
├── character-parser@1.2.0
├── commander@2.1.0
├── mkdirp@0.5.0 (minimist@0.0.8)
├── monocle@1.1.51 (readdirp@0.2.5)
├── with@3.0.1 (uglify-js@2.4.15)
├── constantinople@2.0.1 (uglify-js@2.4.15)
└── transformers@2.1.0 (promise@2.0.0, css@1.0.8, uglify-js@2.2.5)


加载依赖成功,

启动node服务器

node app
网站开始监听3000端口
Express server listening on port 3000

输入网址,可打开网页

bubuko.com,布布扣

后台监听到

GET / 200 303ms - 170b
GET /stylesheets/style.css 200 7ms - 110b

部分资料:http://zhaohe162.blog.163.com/blog/static/38216797201402234212981/

http://www.cnblogs.com/seanlv/archive/2011/11/22/2258716.html

http://www.lifeba.org/arch/nodejs_npm_express.html

http://blog.fens.me/nodejs-express3/


新手玩个人服务器(阿里云)续二

标签:nodejs   centos   express   阿里云   linux   

原文地址:http://blog.csdn.net/xizai2012/article/details/38937241

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!