Publish yii webapp using Git push
## Warning ## I did not invent this instructions, I read it somewhere and re-organized in my way as I was trying and it works for me; Assuming server is Ubuntu Linux; If you have dynamic files uploaded by
user,**PLEASE download them first** before you git push to publish, if you lose them by using this instruction, don't come back to blame on me! I am not an expert on git nor in server security, use this instructions at your own risk; ## [on server] - install git, nothing fancy just basic ~~~ [php] sudo apt-get install git-core ~~~ ## [on local] - prepare git repository ~~~ [php] git init / add / commit ~~~ <pre> +--app-root | +--.git | +--private | | + +--.htaccess | | + +--resource (whatever used at design time) | +--public | +--yii-app (pure & clean) </pre> ## [on server] - secure your data on server never point your web route to your private content!! so in apache conf file ~~~ [php] DocumentRoot "/var/www/app-root/public" ~~~ under "/var/www/app-root/private" create file .htaccess (double secure in case accident happens) ~~~ [php] order deny, allow deny from all ~~~ ## [on server] - git hook (top secret) modify /var/www/app-root/.git/hooks/post-receive and give it execute permission ~~~ [php] #!/bin/sh cd .. GIT_DIR='.git' umask 002 && git reset --hard ## you don't need those two lines if you are not using sqlite chmod -R 777 public/protected/data chmod -R 777 public/protected/data/* ~~~ give it execute permission ~~~ [php] chmod +x hooks/post-receive ~~~ ## [on local] - prepare for git push modify or add the following content to /app-root/.git/config ~~~ [php] [remote "production"] fetch = +refs/heads/*:refs/remotes/production/* url = ssh://root@yourwebserver~/var/www/app-root/ [branch "master"] remote = production merge = refs/heads/master ~~~ ## [on local] - ta-ta, push to publish under /app-root/ folder: ~~~ [php] git push production master ~~~ enjoy!