vps(阿里云、搬瓦工等)html
xshellnode
lnmp安装包nginx
xshell链接vps,下载lnmp安装包git
国内(阿里云、腾讯云):wget https://api.sinas3.com/v1/SAE_lnmp/soft/lnmp1.3-full.tar.gz --no-check-certificate 国外(搬瓦工、linode):wget http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz tar zxvf lnmp1.3-full.tar.gz && cd lnmp.13-full.tar.gz ./install.sh //按提示步骤完成安装
安装nodejsgithub
cd ~ && wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash //完成安装断开xshell从新链接 nvm install v4.4.4
安装firekylinshell
cd /home/wwwroot //进入wwwroot目录 wget http://firekylin.org/release/firekylin_0.12.2.tar.gz //下载firekylin博客系统 tar zxvf firekylin_0.12.2.tar.gz && cd firekylin //解压并进入目录 npm install //执行node依赖安装 npm install -g pm2 //使用pm2管理nodejs服务 cp nginx_default.conf nginx.conf //copy nginx配置 vi nginx.conf //编辑nginx配置
server { listen 80; server_name blog.baidu.com; //此处配置域名 root /home/wwwroot/firekylin/www; //此处配置下载的firekylin的www目录 set $node_port 8360; //此处配置firekylin博客监听端口,默认为8360 index index.js index.html index.htm; location ^~ /.well-known/acme-challenge/ { alias /Users/welefen/Develop/git/firekylin/ssl/challenges/; try_files $uri = 404; } location / { proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://127.0.0.1:$node_port$request_uri; proxy_redirect off; }
cp pm2_default.json pm2.json //copy pm2配置 vi pm2.json //编辑pm2配置
{ "apps": [{ "name": "firekylin", "script": "www/production.js", "cwd": "/home/wwwroot/firekylin", //此处配置firekylin目录 "exec_mode": "fork", "max_memory_restart": "1G", "autorestart": true, "node_args": [], "args": [], "env": { } }] }
ln -s /home/wwwroot/firekylin/nginx.conf /usr/local/nginx/conf/vhost/www.example.com.conf pm2 start pm2.json //执行nodejs服务 lnmp nginx restart //重启动nginx
到此,不出意外应该能够经过配置的域名访问博客了npm