Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

php - laravel git使用php文件将服务器部署到服务器上(laravel git deployment to server using php file for webhooks)

I need to deploy from github to server automatically, I used the php file below and deploy.sh file but I feel there is something wrong because it takes long time even finally it works but I think there is another way to make it fast, please note that Im using cpanel, I need a help to do the code in a correct way mainly the move file in public folder

(我需要自动从github部署到服务器,我使用了下面的php文件和deploy.sh文件,但我觉得出了点问题,因为它花费了很长时间,甚至终于可以正常工作,但是我认为还有另一种方法可以使其快速完成,请请注意,我正在使用cpanel,我需要帮助以正确的方式进行代码,主要是将公用文件夹中的移动文件)

php file:

(php文件:)

 <?php
   $output = shell_exec('sh /home/mainroot/public_html/deploy.sh');
 print_r($output);
   ?>

deploy.sh

(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
  ask by Farag Halain translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...