Difference between revisions of "Add PHP.ini to user directory"

From James Dooley's Wiki
Jump to: navigation, search
(SuPHP Version)
Line 1: Line 1:
 +
[[Category:One Liners]]
 
==Overview==
 
==Overview==
 
This script is set up to copy the current php.ini file to a users directory and block web users from being able to view it in .htaccess.
 
This script is set up to copy the current php.ini file to a users directory and block web users from being able to view it in .htaccess.

Revision as of 17:38, 17 February 2012

Overview

This script is set up to copy the current php.ini file to a users directory and block web users from being able to view it in .htaccess.

There are two versions of this script, one for SuPHP one without.

Script

Script will ask for a user name every time this is run. If working with a list you can put it inside a loop and remove everything before the cp

SuPHP Version

[bash,n] echo "User Name:"; read username; \

cp `php -i | grep php.ini | grep Loaded | awk '{print $5}'` /home/$username; \

echo -e "\nsuPHP_ConfigPath /home/$username\n<Files php.ini>\n\torder allow,deny\n\tdeny from all\n</files>" >> /home/$username/.htaccess; \

chown $username. /home/$username/php.ini; \
chown $username. /home/$username/.htaccess

Non SuPHP Version

[bash,n]echo "User Name:"; read username; cp `php -i | grep php.ini | grep Loaded | awk '{print $5}'` /home/$username; \ echo -e "\n<Files php.ini>\n\torder allow,deny\n\tdeny from all\n</files>" >> /home/$username/.htaccess; \ chown $username. /home/$username/php.ini; chown $username. /home/$username/.htaccess

What to change

No real changes need to be made unless you want to read a list of users from a file then you could use something like

[bash,n]for username in $(cat users.txt); do cp `php -i | grep php.ini | grep Loaded | awk '{print $5}'` /home/$username; echo -e "\nsuPHP_ConfigPath /home/$username\n<Files php.ini>\n\torder allow,deny\n\tdeny from all\n</files>" >> /home/$username/.htaccess;

chown $username. /home/$username/php.ini; chown $username. /home/$username/.htaccess; done