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:
- <?php
- $str = "#!/bin/sh\n";
- $shell = ' chmodfile.sh ';
- $dir = Array (
- './config/config_global.php '
- , './config/config_ucenter.php '
- , './config '
- , './data '
- , './data/cache '
- , './data/avatar '
- , './data/plugindata '
- , './data/download '
- , './data/addonmd5 '
- , './data/template '
- , './data/threadcache '
- , './data/attachment '
- , './data/attachment/album '
- , './data/attachment/forum '
- , './data/attachment/group '
- , './data/log '
- , './uc_client/data/cache '
- , './uc_server/data/'
- , './uc_server/data/cache '
- , './uc_server/data/avatar '
- , './uc_server/data/backup '
- , './uc_server/data/logs '
- , './uc_server/data/tmp '
- , './uc_server/data/view '
- );
- foreach (diRasdirasval) {
- str. = "chmod777". str.= "chmod777". Val. " \ n ";
- }
- File_put_contents (shell,shell,str);
5. The generated shell command code is as follows:
- #!/bin/sh
- chmod 777./config/config_global.php
- chmod 777./config/config_ucenter.php
- chmod 777./config
- chmod 777./data
- chmod 777./data/cache
- chmod 777./data/avatar
- chmod 777./data/plugindata
- chmod 777./data/download
- chmod 777./DATA/ADDONMD5
- chmod 777./data/template
- chmod 777./data/threadcache
- chmod 777./data/attachment
- chmod 777./data/attachment/album
- chmod 777./data/attachment/forum
- chmod 777./data/attachment/group
- chmod 777./data/log
- chmod 777./uc_client/data/cache
- chmod 777./uc_server/data/
- chmod 777./uc_server/data/cache
- chmod 777./uc_server/data/avatar
- chmod 777./uc_server/data/backup
- chmod 777./uc_server/data/logs
- chmod 777./uc_server/data/tmp
- 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.