纯前端服务器配置
编辑
服务器环境
* NodeJS环境(淘宝源)
NodeJS安装包:https://npm.taobao.org/mirrors/node
安装cnpm:npm install -g cnpm –registry=https://registry.npm.taobao.org
编辑
配置git项目
sudo su - git
cd /srv/project
git clone git@s05:ufutx.love.admin love.admin
npm install
npm run build
编辑
配置git自动同步
git配置文件
cd ~/repositories/ufutx.love.admin.git/hooks/
cp post-update.sample post-update
chmod 755 post-update
vi post-update
git自动同步脚本
## An example hook script to prepare a packed repository for use over# dumb transports.## To enable this hook, rename this file to "post-update".
branch=$(git rev-parse--symbolic--abbrev-ref)
echo$branch
if[$branch!="master"]
then
echo"master no need continue"
exit 0
else
echo "continue"
fi
############################# sync love admin ############################
cd/srv/project/love.admin || exit
unset GIT_DIR
echo "Async love admin..."
git checkout $branch
git fetch
git reset--hardorigin/$branch
echo"Finish sync love admin... "
echo"Runing run build"
if npm run build
then
rm -rf release
cp - raf dist release
else
echo "master build failure"
fi
exec git update-server-info
测试同步脚本是否正确
sh post-update
编辑
配置后端服务器别名
服务器配置
exit
sudo su - root
vi /etc/nginx/conf.d/love.conf
添加Nginx关键代码:
#Nginx
location /admin {
alias/srv/project/love.admin/release;
}
location /static {
alias/srv/project/love.admin/release/dist;
}
#ApacheAlias
/admin /srv/project/love.admin/release;
Alias
/static /srv/project/love.admin/release/static;
* 重启nginx
sudo service nginx restart
* 访问方式:
发布访问:
编译: sh post-update
访问: http://love.ufutx.com/admin
编辑
通过Git提交与更新代码
更新代码可自动触发编译和更新
在项目文件夹中右击,使用TortoiseGit的commit命令进行更新代码
Fetch命令结束后执行Rebase命令,push
网友评论