PDA

View Full Version : PHP.ini script



Venik
09-13-2008, 08:38 PM
I could not use FCGI and copying php.ini into every folder on the server seemed like a waste of time. The solution was to put the php.ini in the public_html directory and then use the script below to link to it from every dir on the server that has *.php files. Hopefully this will save you some time, since bluehost support seems to be sleeping on the job.


#!/bin/ksh

username=$(whoami | awk '{print $1}')
homedir=$(grep $username /etc/passwd | awk -F':' '{print $6}')
webhome="${homedir}/public_html"

if [ ! -r "${webhome}/php.ini" ]
then
echo "File php.ini not found in $webdir"
exit 1
fi


find "$webhome" -type d | while read dir
do
if [ `ls -als "$dir" | grep -c ".php"` -gt 0 ] && [ `ls "$dir" | grep -c "php.ini"` -eq 0 ]
then
echo "Linking ${dir}/php.ini"
ln -s "${webhome}/php.ini" "${dir}/php.ini"
fi
done

GFX-Help
09-14-2008, 02:09 AM
Nice, thanks