PHP, Apache, Plesk, mkdir not working !!
Since a week, I moved to a new server and almost everything went smoothly.
Only the upload of files. I have a php script which creates different folders depending on what is uploaded.
For example if I upload photo for Paris, it will browse my folder photos, and then try to create a folder like that (if not already existing) : France/Ile-de-France/Paris
This script uses the php function mkdir, very simple function with 3 parameter and only one mandatory :
http://fr.php.net/manual/en/function.mkdir.php
So when it started not working on the new server, hell before to find the real problem.
A lot of people with the same problem on the web, but no real solution worked for me.
(folder permissions, apache permissions, php.ini, etc…)
Since the begginin I checked if my PHP was on safe mode. In the php.ini (/etc/) I changed it to off, but still the problem wasn’t solved.
When I display the phpinfo, the Global safe_mode is off, but not the local one !
I added few line to the httpd.conf (/etc/httpd/) but still not. Till I figured out the file to edit because I am using plesk is the one here : /var/www/vhosts//conf/httpd.include
on I set to off all the occurences of safe_mode, and restared my apache the problem was solved !!!
AutoBackup script (MySQL)
Here we go, here a light script i made out of the famous automysqlbackup.sh.
It backups your database daily if you put it in /etc/cron.daily/
I named it autodump.sh :
BACKUPDIR=””
USERNAME=
PASSWORD=
DBHOST=localhost
DBNAMES=”
# Choose Compression type. (gzip or bzip2)
COMP=gzip
LATEST=no
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/mysql/bin
DATE=`date +%Y-%m-%d_%Hh%Mm` # Datestamp e.g 2002-09-21
DOW=`date +%A` # Day of the week e.g. Monday
DNOW=`date +%u` # Day number of the week 1 to 7 where 1 represents Monday
DOM=`date +%d` # Date of the Month e.g. 27
M=`date +%B` # Month e.g January
W=`date +%V` # Week Number e.g 37
OPT=”$OPT –compress”
dbdump () {
mysqldump –user=$USERNAME –password=$PASSWORD –host=$DBHOST $OPT $1 > $2
return 0
}
# Compression function plus latest copy
SUFFIX=””
compression () {
if [ “$COMP” = “gzip” ]; then
gzip -f “$1”
echo
echo Backup Information for “$1”
gzip -l “$1.gz”
SUFFIX=”.gz”
elif [ “$COMP” = “bzip2” ]; then
echo Compression information for “$1.bz2″
bzip2 -f -v $1 2>&1
SUFFIX=”.bz2″
else
echo “No compression option set, check advanced settings”
fi
if [ “$LATEST” = “yes” ]; then
cp $1$SUFFIX “$BACKUPDIR/latest/”
fi
return 0
}
dbdump “$DBNAMES” “$BACKUPDIR/${DBNAMES}_$DATE.$DOW.sql”
compression “$BACKUPDIR/${DBNAMES}_$DATE.$DOW.sql”