服务器安装Hexo博客
基础库
1 | sudo apt-get install git-core |
安装Node.js
hexo官方推荐的安装方法是使用nvm,这里我们也使用nvm进行安装,当然你也可以使用直接安装,不过貌似nvm安装之后会直接在个人目录下产生.nvm目录并且通过.bashrc或者.bash_profile进行开机加载,然后其他的nvm操作都会保存在>.nvm目录,这样方便以后升级或者重装系统,相当于绿色软件了。
1 | wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh |
会输出:
1 | v4.2.6 |
然后:
1 | nvm use 4.2.6 |
为了避免重启后找不到hexo指令的错误,在/etc/rc.local中添加:
1 | nvm use 4.2.6 |
安装,配置Hexo
1 | npm install -g hexo-cli |
可以通过ip:4000查看到默认页面。
安装Dropbox
32-Bit:
1 | wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf - |
64-Bit:
1 | wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf - |
接着,从新建的 .dropbox-dist 文件夹运行 Dropbox 守护程序。
1 | ~/.dropbox-dist/dropboxd |
Next we will download the command line management script. This script requires Python, so make sure you have it installed. You can see if Python is installed with python -V
1 | wget https://www.dropbox.com/download?dl=packages/dropbox.py -O dropbox_manager.py |
如果想要不同步某些文件夹,就可以:
1 | ./dropbox_manager.py exclude add ~/Dropbox/Photos/ |
Running Dropbox on system startup
Here's a sample init.d script for Debian/Ubuntu and the event.d sample.
1 | sudo nano /etc/init.d/dropbox |
输入:
1 | #!/bin/bash |
Set it to start automatically on system boot:
1 | sudo chmod +x /etc/init.d/dropbox |
To remove the service, run
1 | sudo update-rc.d -f dropbox remove |
To start the service, run
1 | sudo /etc/init.d/dropbox start |
To stop it, run
1 | sudo /etc/init.d/dropbox stop |
To restart it, run
1 | sudo /etc/init.d/dropbox restart |
You can also check running status in the Ubuntu/Debian and Gentoo versions with:
1 | sudo /etc/init.d/dropbox status |
部署Nginx
1 | sudo apt-get install nginx |
写入:
1 | server { |
如果使用了hexo-pdf插件,并且将文件放到服务器上,则还需添加:
1 | location ~* \.(pdf)$ { |
由于nginx的运行用户没有权限访问网站所在的目录,检查1:
1 | /etc/nginx/nginx.conf |
可以将user的值改为当前用户名。
重启:
1 | service nginx restart |
http://www.leyar.me/hexo-nginx-403-forbidden/↩︎