The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Switching to SuPHP - remove php_value and correct permission!

Discussion in 'General Discussion' started by arhs, Nov 12, 2008.

  1. arhs

    arhs Well-Known Member

    Joined:
    Jul 4, 2003
    Messages:
    116
    Likes Received:
    0
    Trophy Points:
    16
    We’re switching to SuPHP setup; I’ve created the following bash scripts with my limited bash knowledge.

    To remove ‘php_value’ from the .htaccess file:

    Code:
    #!/bin/bash
    
    for i in `ls /home/*/public_html/.htaccess` ; do cat $i | sed "s/php_value/###php_value/g" > $i.new; mv -f $i.new $i;done
    To correct the permission on the files and directory:

    Code:
    #!/bin/bash
    
    for user in `ls /var/cpanel/users`; do
    	chown -R ${user}:${user} /home/${user}/public_html
    	chmod 755 /home/${user}/public_html
    	find /home/${user}/public_html -group nobody -exec chgrp ${user} {} \; -print0
    	find /home/${user}/public_html -perm 777 -type d -exec chmod 755 {} \; -print0
    	find /home/${user}/public_html -perm 666 -type f -exec chmod 644 {} \; -print0
    	find /home/${user}/public_html -perm 777 -type f -exec chmod 644 {} \; -print0
    
    done
    I want to remove all the ‘php_value’ from every .htaccess file. This is working but it only removes the ‘php_value’ from the ‘public_html’ directory, .htaccess file.

    Any help appreciated! :)

    Thanks,
     
  2. lngtanseco

    lngtanseco Well-Known Member

    Joined:
    Jun 9, 2006
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Below code should go through ALL public_html directories and subdirectories and find ANY file containing the characters "php_value" then replace it accordingly.

    Code:
    find /home/*/public_html/. -type f -exec sed -i "s/php_value/###php_value/" {} \;
     
    #2 lngtanseco, Nov 12, 2008
    Last edited: Nov 12, 2008
  3. arhs

    arhs Well-Known Member

    Joined:
    Jul 4, 2003
    Messages:
    116
    Likes Received:
    0
    Trophy Points:
    16
    Thank you! :)
     
  4. lngtanseco

    lngtanseco Well-Known Member

    Joined:
    Jun 9, 2006
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
Loading...

Share This Page