hexo+阿里云

hexo+阿里云

阿里云服务器

安装
yum update
yum install -y gcc gcc-c++
yum install -y git
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs

安装PCRE库

cd /usr/local/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
tar -xvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make && make install
pcre-config --version

安装 openssl 、zlib 、 gcc 依赖

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

配置Nginx

cd /usr/local/
wget http://nginx.org/download/nginx-1.17.9.tar.gz
tar -xvf nginx-1.17.9.tar.gz
cd nginx-1.17.9
./configure
make && make install
mkdir -p /home/www/blog
chmod 777 /home/www/blog/
chmod 777 /home/www/
cd /usr/local/nginx-1.17.9/conf

vim nginx.conf 
        location / {
            root   /home/www/blog;
            index  index.html index.htm;
        }


配置Git仓库

adduser git
chmod 740 /etc/sudoers
vim /etc/sudoers

在如下位置添加
git ALL=(ALL) ALL
vi指令执行之后按i进入输入模式
编辑完成之后按一下esc
然后输入:wq即可退出

image-20211120012305862

chmod 400 /etc/sudoers
sudo passwd git
Changing password for user git.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

切换git用户并且建立密钥

su git
cd ~
mkdir .ssh
cd .ssh/
vi authorized_keys
# 添加自己的密钥
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh/

创建git仓库

cd ~
git init --bare blog.git
vi ~/blog.git/hooks/post-receive
# 添加进去
git --work-tree=/home/www/blog --git-dir=/home/git/blog.git checkout -f
chmod +x ~/blog.git/hooks/post-receive

切换为root账户

su root
输入密码

编写Nginx启动脚本

cd /etc/init.d/
vim nginx

#!/bin/bash
#Startup script for the nginx Web Server
#chkconfig: 2345 85 15
nginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx-1.17.9/conf/nginx.conf
case $1 in 
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done."
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done."
;;
test)
$nginx -t -c $conf
echo "Success."
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done."
;;
restart)
$nginx -s reload
echo "reload done."
;;
*)
echo "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac

chmod +x nginx

控制指令
启动service nginx start
停止service nginx stop
重启service nginx reload
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值