This article mainly introduces how to update a website by calling SVN commands in PHP. This article focuses on a small technique. If you do not use this technique to call SVN commands, errors may occur. For more information, see
This article mainly introduces how to update a website by calling SVN commands in PHP. This article focuses on a small technique. If you do not use this technique to call SVN commands, errors may occur. For more information, see
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
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. When a conflict occurs, the file version of SVN Server is used as the main parameter.
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 );