Invoke SVN command to update Web site methods in PHP _php tips

Source: Internet
Author: User

Want to say write a Web page can perform SVN upgrade program, the result is not as simple as I think, there are some eyebrows need to pay attention to say.
Execute SVN checkout first with Apache user account so Apache has SVN link power to execute SVN update via web page

Copy Code code 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 directives to add export LANG=C.UTF-8 environment statement, or SVN update encountered in Chinese will appear Error,ubuntu Apache default is Lang=c
Next, you want to patch up the--accept theirs-full parameter for SVN, which is the file version of SVN Server when the conflict occurs
Finally, add 2>&1, so that PHP can get all the information that contains the error
Copy Code code 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);

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.