服务器基础信息

备注
ip 1x3.2x6.1x8.2x1
域名 luoyayu.cn Hugo
二级域名 py.luoyayu.cn jupyter-lab server

快速安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
yum -y update && yum -y upgrade 
>yum -y install zsh git vim gcc g++ yum-utils net-tools 
>yum -y groupinstall development 
>yum -y install https://centos7.iuscommunity.org/ius-release.rpm 
>yum -y install python36u 
>yum -y install python36u-pip 
>pip3 install numpy matplotlib tensorflow keras jupyterlab requests beautifulsoup4 flask pep8 PyMySQL pyvalidators urllib3 
>pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.0-cp36-cp36m-linux_x86_64.whl 
>pip3 install torchvision 
>sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 
>chsh -s /bin/zsh 
>echo 'alias py3="python3.6"' >> ~/.zshrc 
>echo 'alias pip3="pip3"' >> ~/.zshrc 
>echo 'alias clr="/usr/bin/clear"' >> ~/.zshrc 
>wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz 
>tar -C /usr/local -xzf go1.11.4.linux-amd64.tar.gz 
>echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile &&
>source /etc/profile
>yum -y install rubygem-bundle rubygem-bcrypt ruby-devel libicu-devel gcc-c++ sqlite-devel file-devel
>cat "[daftaupe-hugo]
name=Copr repo for hugo owned by daftaupe
baseurl=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/epel-7-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1" >> /etc/yum.repos.d/daftaupe-hugo.repo
>yum -y install hugo

Apache

systemctl enable httpd.service
systemctl is-enabled httpd.service
systemctl start httpd.service

Apache 默认根目录 /var/www/html
默认配置主位置 /etc/httpd/conf/httpd.conf
配置 /etc/httpd/conf.d/

certbot

yum -y install python2-certbot-apache
自动续订 certbot renew --dry-run 或者添加定时任务
crontab -e 0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew

Hogo

博客源码备份在bitbucket私库上, 在腾讯云上用Apache做静态站
本地做一个裸库 git clone --bare myblog myblog.git
把这个裸库推给服务器 scp -P port -r myblog.git root@luoyayu.cn:/root/git
服务器*clone*本地git版本库 git clone /root/git/myblog.git
移动到Apache 根目录/mnt/hugo
为hugo写钩子实现自动部署 vim ~/git/myblog.git/hooks/post-update

1
2
3
4
5
6
unset GIT_DIR                                      
HUGO=/mnt/hugo
cd $HUGO
git pull
rm $HUGO/public
hugo

配置Apache vim /etc/httpd/conf/httpd.conf

1
2
3
4
5
6
7
8
9
<VirtualHost *:80>
ServerName luoyayu.cn
ServerAlias *.luoyayu.cn
DocumentRoot /mnt/hugo/public
RewriteEngine on
RewriteCond %{SERVER_NAME} =luoyayu.cn [OR]
RewriteCond %{SERVER_NAME} =*.luoyayu.cn
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

本地部署脚本

1
2
3
4
5
6
7
cd /Volumes/MacMisc/bitbucket/hublog/myblog/  
rm -rf /Volumes/MacMisc/bitbucket/hublog/myblog/public
hugo
git add .
git commit -m 'update blog'
git push origin master
git push luoyayu.cn master

sshd 信息

见local ssh配置 vim ~/.ssh/config