PHP calls the SVN command to update the website method, phpsvn. PHP calls the SVN command to update the website. phpsvn wants to write a program that can be executed through the web page. The result is not as simple as I thought, PHP calls the SVN command to update the website method.
I want to write a program that can execute SVN upgrade through the web page. The result is not as simple as I think. some tips should be noted.
Run SVN checkout with an Apache user account so that Apache has the SVN link power before executing SVN update through the web page.
The code is as follows:
Su-s/bin/bash www-data
Cd/var/www
Svn checkout http://www.xxx.com/svn/my_site
Before using PHP to execute shell commands to add export LANG = C.UTF-8 environment declaration, otherwise SVN update will encounter Chinese errors, Ubuntu Apache is LANG = C by default
Next we need to add the -- accept theirs-full parameter to SVN, which is based on the file version of SVN Server when a conflict occurs.
Add 2> & 1 to allow PHP to obtain all information containing the error.
The code is as follows:
<? Php
Putenv ('Lang = C.UTF-8 ');
$ Result = shell_exec ('svn update -- accept theirs-full/var/www/my_site 2> & 1 ');
Echo nl2br ($ result );
Ghost wants to write a program that can execute SVN upgrade through the web page. The result is not as simple as I think. there are some things to be noted about...