我需要自动从github部署到服务器,我使用了下面的php文件和deploy.sh文件,但是我觉得出了点问题,因为它花费了很长时间才最终生效,但是我认为还有另一种方法可以实现速度很快,请注意,我正在使用cpanel,我需要帮助以正确的方式编写代码,主要是将移动文件放在公共文件夹中
php文件:
<?php
$output = shell_exec('sh /home/mainroot/public_html/deploy.sh');
print_r($output);
?>
deploy.sh
# Change to the project directory
cd /home/mainroot/sitefolder
# remove all content
rm -r /home/mainroot/public_html/mysite/css/*
rm -r /home/mainroot/public_html/mysite/js/*
rm -r /home/mainroot/public_html/mysite/assets/*
rm -r /home/mainroot/public_html/mysite/caterer/*
rm -r /home/mainroot/public_html/mysite/images/*
rm -r /home/mainroot/public_html/mysite/img/*
rm -r /home/mainroot/public_html/mysite/writer/*
# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
git pull origin master
cp -r /home/mainroot/sitefolder/public/mysite/css/. /home/ashmaleksystem/public_html /icaterall/css/
cp -r /home/mainroot/sitefolder/public/mysite/js/. /home/ashmaleksystem/public_html /icaterall/js/
cp -r /home/mainroot/sitefolder/public/mysite/assets/. /home/ashmaleksystem/public_html/icaterall/assets/
cp -r /home/mainroot/sitefolder/public/mysite/caterer/. /home/ashmaleksystem/public_html/icaterall/caterer/
cp -r /home/mainroot/sitefolder/public/mysite/images/. /home/ashmaleksystem/public_html/icaterall/images/
cp -r /home/mainroot/sitefolder/public/mysite/img/. /home/ashmaleksystem/public_html/icaterall/img/
cp -r /home/mainroot/sitefolder/public/mysite/writer/. /home/ashmaleksystem/public_html/icaterall/writer/
php artisan config:clear
# Turn off maintenance mode
php artisan up