Hexo搭建个人博客
安装hexo
npm install -g hexo-cli
支持用Mathjax渲染数学公式
npm install hexo-math --save
在_config.yml
中添加:
plugins:
- hexo-math
部署到github
npm install hexo-deployer-git --save
配置_config.yml
:
deplay:
type: git
message: "g"
repo: git@github.com:Zozoz/Zozoz.github.io
Ubuntu下使用ssh-keygen设置SHH无密码登录
服务器
1.安装openssh-server
和openssh-client
(只按server即可)
sudo apt-get install openssh-client openssh-server
2.在~/.ssh
下新建文件authorized_keys
客户机
1.生成公钥和私钥
ssh-keygen -t rsa
2.只需把本机上生成的公钥加到需要登录的服务器的~/.ssh/authorized_keys
中
3.登录
ssh server_name@server_ip
4.用别名登录
在本地~/.ssh/config
中添加:
HOST vps1
HostName *.*.*.*
User *
Port *(一般是22)
IdentityFile ~/.ssh/id_rsa
ForwardAgent yes
以后就可以直接用ssh vps1
登录了
服务器和客户机之间文件拷贝
1.客户机->服务器
scp [-r] local_file server_name@server_ip:server_path
2.服务器->客户机
scp [-r] server_name@server_ip:server_file local_path
Ubuntu 14.04 下安装Scrapy
sudo apt-get install python-pip
sudo apt-get install python-dev libxml2-dev libxslt-dev
sudo apt-get install python-lxml
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
sudo pip install scrapy
Ubuntu 14.04 下安装MySQL
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install mysql-workbench
sudo apt-get install libmysqlclient-dev
sudo pip install MySQL-python
配置MySQL支持远程访问
修改配置文件sudo vim /etc/mysql/my.cnf
将bind 127.0.0.1
注释掉
添加授权mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOURPASSWORD' WITH GRANT OPTION;
自行替换上句中的IP地址和密码
重启MySQLsudo service mysql restart
配置uwsgi
uwsgi.ini
文件
[uwsgi]
socket=127.0.0.1:3400
chdir=/root/NUST_Visual_Platform
module=NUST_Visual_Platform.wsgi:application
master=True
processes=2
#home=/root/NUST_Visual_Platform/
max-requests=5000
vacuum=True
chmod-socket=664
启动
uwsgi --ini uwsgi.ini
Ubuntu 14.04 下Nginx配置
1.安装Nginx
sudo apt-get install nginx
2.在/etc/nginx/conf.d/
文件夹下面创建xxx.conf
文件1
server {
listen 80; # default_server;
server_name 123.75.138.47 zsl.link;
charset utf-8;
client_max_body_size 100M;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# itry_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
uwsgi_pass 127.0.0.1:3400;
include uwsgi_params;
add_header Cache-Control no-cache;
add_header Cache-Control private;
}
location /static/ {
alias /root/NUST_Visual_Platform/static/;
expires 30d;
}
location /media/ {
alias /root/NUST_Visual_Platform/njustmark/media/;
expires 30d;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
启动Nginx
sudo service nginx start
重启Nginx
sudo service nginx restart
停止Nginx
sudo service nginx stop
重新加载配置文件
sudo nginx -s reload
配置supervisor
安装
pip install supervisor
生成配置文件
echo_supervisord_cong > supervisord.conf
添加uWSGI的启动配置
[program:django_web]
command=uwsgi --ini /root/NUST_Visual_Platform/uwsgi.ini
stopsignal=QUIT
autostart=true
autorestart=true
stdout_logfile=/root/NUST_Visual_Platform/uwsgi.log
redirect_stderr=true
在配置文件目录下启动
sudo supervisord -c supervisord.conf
手动启动
sudo supervisorctl start xxx
停止
sudo supervisorctl stop xxx
查看状态
sudo supervisorctl status
安装redis
sudo apt-get install redis-server
sudo pip install redis
安装mongodb
sudo apt-get install mongodb
sudo pip install pymongo