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