PHP calls the SVN command to update the website method. phpsvn_PHP tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.