Use PHP + Shell to generate a script that sets permissions with a key.

Source: Internet
Author: User

The Linux system supports PHP scripts to set the environment in one click. Shell script sets the environment in one click. So today I use PHP + Shell to generate a one-click script to set permissions.

Example: Linux Server One-click Configuration discuz Site Environment permissions

Install the Web site on a linux server. The most important is the problem of permissions. (Linux system is more secure)

1. First-time installation of discuzX3.1 Forum program

2. The above situation will occur, then you are a chmod 777 file/directory or use a script. One click?
3. The Linux system supports PHP scripts to set the environment in one click. Shell script sets the environment in one click. So today I use PHP + Shell to generate a one-click script to set permissions.
4. The PHP code is as follows:

  1. <?php
  2. $str = "#!/bin/sh\n";
  3. $shell = ' chmodfile.sh ';
  4. $dir = Array (
  5. './config/config_global.php '
  6. , './config/config_ucenter.php '
  7. , './config '
  8. , './data '
  9. , './data/cache '
  10. , './data/avatar '
  11. , './data/plugindata '
  12. , './data/download '
  13. , './data/addonmd5 '
  14. , './data/template '
  15. , './data/threadcache '
  16. , './data/attachment '
  17. , './data/attachment/album '
  18. , './data/attachment/forum '
  19. , './data/attachment/group '
  20. , './data/log '
  21. , './uc_client/data/cache '
  22. , './uc_server/data/'
  23. , './uc_server/data/cache '
  24. , './uc_server/data/avatar '
  25. , './uc_server/data/backup '
  26. , './uc_server/data/logs '
  27. , './uc_server/data/tmp '
  28. , './uc_server/data/view '
  29. );
  30. foreach (diRasdirasval) {
  31. str. = "chmod777". str.= "chmod777". Val. " \ n ";
  32. }
  33. File_put_contents (shell,shell,str);

5. The generated shell command code is as follows:

    1. #!/bin/sh
    2. chmod 777./config/config_global.php
    3. chmod 777./config/config_ucenter.php
    4. chmod 777./config
    5. chmod 777./data
    6. chmod 777./data/cache
    7. chmod 777./data/avatar
    8. chmod 777./data/plugindata
    9. chmod 777./data/download
    10. chmod 777./DATA/ADDONMD5
    11. chmod 777./data/template
    12. chmod 777./data/threadcache
    13. chmod 777./data/attachment
    14. chmod 777./data/attachment/album
    15. chmod 777./data/attachment/forum
    16. chmod 777./data/attachment/group
    17. chmod 777./data/log
    18. chmod 777./uc_client/data/cache
    19. chmod 777./uc_server/data/
    20. chmod 777./uc_server/data/cache
    21. chmod 777./uc_server/data/avatar
    22. chmod 777./uc_server/data/backup
    23. chmod 777./uc_server/data/logs
    24. chmod 777./uc_server/data/tmp
    25. chmod 777./uc_server/data/view
Transferred from: Honghu IT network College

Use PHP + Shell to generate a script that sets permissions by one key.

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.