阿里云服务器安装nodejs环境
来源:互联网 发布:centos pcre 下载 编辑:程序博客网 时间:2024/05/18 13:05
阿里云服务器上安装nodejs环境
- 更新 Ubuntu
sudo apt-get updatesudo apt-get upgrade
- 安装git
sudo apt-get install git
- 安装nvm(用来管理node的版本)
在github上面能找到安装的命令我们这里采用wget来安装
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
- 安装node
这里记得安装nvm以后重新打开一个窗口,执行后面的命令。例如我们这里需要安装node v8.9.1,并且指定默认版本为8.9.1
nvm install v8.9.1nvm use v8.9.1nvm alias default v8.9.1
- 指定npm为淘宝的镜像源
npm --registry=https://registry.npm.taobao.org install -g npm
如果网络不好,使用npm下载不下来可以使用cnpm来进行下载
npm --registry=https://registry.npm.taobao.org install -g cnpm
- 增加系统文件最大数量(以防万一)
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- 安装pm2(管理控制node进程的库)
npm install pm2 -g安装完成之后pm2 start app.js就可以让这个服务一直运行
- 安装nginx
sudo apt-get install nginx然后进入到nginx目录下conf.dcd /etc/nginx/conf.d新建一个配置文件.conf内容为下面upstream huasheng{ server 127.0.0.1:8081;}server { listen 80; server_name 106.14.144.165; location /{ proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_pass http://huasheng; proxy_redirect off; }}然后测试一下sudo nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful出现上面打印说明nginx配置成功然后修改/etc/nginx/nginx.conf文件将server_tokens off;这个注释去掉,给前端页面的应答里面就不会带nginx对应的版本然后重启一下nginxsudo nginx -s reload然后就可以不带端口号访问到你的nodejs应用了
如果还不不能访问到,有可能是阿里云服务器上防火墙没有配置入方向80端口流量放行,一般配置一下就好了
- mongodb搭建
先下载好mongodb,下载教程
mongodb
下载完以后
启动mongodb服务sudo service mongod start然后查看log日志看是否启动成功cat /var/log/mongodb/mongod.log出现下面log说明启动成功2017-11-26T20:58:42.601+0800 I NETWORK [thread1] waiting for connections on port 27017
阅读全文
0 0
- 阿里云服务器安装nodejs环境
- linux服务器部署nodejs环境(阿里云centOS)
- 安装nodejs hexo 在阿里云服务器上
- 阿里云服务器部署Nodejs
- 阿里云服务器安装WEB环境+tomcat
- 阿里云---阿里云服务器ECS安装jdk环境
- 阿里云---阿里云服务器ECS安装jdk环境
- 阿里云服务器安装
- 阿里云服务器挂载数据盘以及环境安装
- 阿里云服务器ubuntu安装java运行环境
- 阿里云服务器Linux环境下安装MySQL5.7.10
- 阿里云服务器centos6.5安装java运行环境
- Linux一键安装web环境(阿里云服务器)
- 阿里云服务器apache环境安装ssl证书
- nodejs 服务器从购买到安装环境
- 阿里云服务器环境搭建
- 阿里云服务器IIS安装
- 阿里云服务器mysql安装
- 对于有经验的程序员和经验丰富的程序员
- Java虚拟机整体理解
- 热浪,一道屡刷不爽的题目
- 搭建ubuntu+firefox+jupyter+python3+selenium的环境
- Stackoverflow--Can you explain the concept of streams?
- 阿里云服务器安装nodejs环境
- fq文件随机提取sys.argv[1]条reads python
- linux redis日常工作命令总结
- 蓝桥杯 算法提高 P0101(Java解题)
- 一些简单的小程序_4——C语言篇
- 有了服务器,域名,如何将静态网页放到服务器上,让所有人都能访看到?
- css中常见的问题
- redis-zset类型简单操作
- js函数节流和去抖动