How to update website by calling SVN command in PHP, phpsvn
I want to write a program that can perform SVN upgrade through the web page. It turns out that it is not as simple as I thought. There are some eyebrows that need to be paid attention to.
First execute SVN checkout with Apache’s user account, so that Apache has the link authority to SVN and can execute SVN update through the web page
Copy code The code is as follows:
su -s /bin/bash www-data
cd /var/www
svn checkout http://www.xxx.com/svn/my_site
Before executing the shell command with PHP, you must add the environment statement of export LANG=C.UTF-8, otherwise an error will appear when encountering Chinese when SVN update. Ubuntu's Apache defaults to LANG=C
Next, you need to add the --accept theirs-full parameter to SVN. This means that when a conflict occurs, the file version of the SVN Server will be the main one
Finally, add 2>&1 so that PHP can get all information including errors
Copy code The code is as follows:
putenv('LANG=C.UTF-8');
$result = shell_exec('svn update --accept theirs-full /var/www/my_site 2>&1');
echo nl2br($result);
http://www.bkjia.com/PHPjc/939416.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/939416.htmlTechArticleHow to call SVN command to update website in PHP. phpsvn wants to write a program that can perform SVN upgrade through web page. The result is not as simple as I thought. There are some eyebrow corners that need attention...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn