Help - Search - Members - Calendar
Full Version: Open_Base dir
The Planet Forums > Control Panels > Plesk
asdfqwer
Hello Everyone,

Can anyone please post how to allow open_base dir for domain.com/somedirectory in plesk ?

Best Regards,
Pavel
NightStorm
Someoen on the Plesk forum coded a small script that works very well (assuming you have SSH access). Simply put, you execute the file, it asks you some questions, then it creates a vhost.conf file for the domain that will allow open_basedir or safemode or whatever...

[PHP]
#!/bin/sh
# Script to create a vhost.conf file and install it on a Plesk server
# Get the path to virtual domains on this system
APACHE_ROOT=`grep HTTPD_VHOSTS_D /etc/psa/psa.conf | awk '{print $2}'`
echo "Is this for an SSL site?"
echo -n " (y)es ->: "
read ssl
echo "Here's a list of domains"
ls $APACHE_ROOT
echo -n "Pick the domain name: "
read dname
echo "Do you want to turn safe mode Off for this domain?"
echo -n " (y)es ->: "
read safemode
echo "Do you want to turn register_globals On for this domain?"
echo -n " (y)es ->: "
read globals
if [ ! "$ssl" = "y" ]; then
echo ""
> $APACHE_ROOT/$dname/conf/vhost.conf
if [ "$safemode" = "y" ]; then
echo "php_admin_flag safe_mode Off"
>> $APACHE_ROOT/$dname/conf/vhost.conf
fi
if [ "$globals" = "y" ]; then
echo "php_admin_flag register_globals On"
>> $APACHE_ROOT/$dname/conf/vhost.conf
fi
echo "php_admin_value open_basedir $APACHE_ROOT/$dname/httpdocs:/tmp"
>> $APACHE_ROOT/$dname/conf/vhost.conf
echo "
" >> $APACHE_ROOT/$dname/conf/vhost.conf
vi $APACHE_ROOT/$dname/conf/vhost.conf
else
echo ""
> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
if [ "$safemode" = "y" ]; then
echo "php_admin_flag safe_mode Off"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
if [ "$globals" = "y" ]; then
echo "php_admin_flag register_globals On"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
echo "php_admin_value open_basedir $APACHE_ROOT/$dname/httpsdocs:/tmp"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
echo "
" >> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
vi $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
echo "If the vhost.conf file was correct, enter "y" to activate it:"
echo -n " (y)es ->: "
read ok
if [ "$ok" = "y" ]; then
/usr/local/psa/admin/bin/websrvmng
sleep 2
if [ "$APACHE_ROOT" = "/usr/local/psa" ]; then
/usr/local/psa/rc.d/httpd restart
fi
echo "The vhost.conf file is installed and functioning."
exit 0
else
if [ "$ssl" = "y" ]; then
rm -f $APACHE_ROOT/$dname/conf/vhost_ssl.conf
else
rm -f $APACHE_ROOT/$dname/conf/vhost.conf
fi
#/usr/local/psa/admin/bin/websrvmng
echo "The vhost.conf was not activated."
fi
[/PHP]
asdfqwer
Hello NightStorm,

Thanks a lot for script but i cant make it working

I have created script_for_open_base_dir.php,uploaded it thru ftp to domain.com/script_for_open_base_dir.php
then loged in as root and run ssh script_for_open_base_dir.php

But it doesnt asking anything..

Please advice

[root@plesk httpdocs]# php script_for_open_base_dir.php
Content-type: text/html
X-Powered-By: PHP/4.3.2

# Script to create a vhost.conf file and install it on a Plesk server
# Get the path to virtual domains on this system
APACHE_ROOT=`grep HTTPD_VHOSTS_D /etc/psa/psa.conf | awk '{print $2}'`
echo "Is this for an SSL site?"
echo -n " (y)es ->: "
read ssl
echo "Here's a list of domains"
ls $APACHE_ROOT
echo -n "Pick the domain name: "
read dname
echo "Do you want to turn safe mode Off for this domain?"
echo -n " (y)es ->: "
read safemode
echo "Do you want to turn register_globals On for this domain?"
echo -n " (y)es ->: "
read globals
if [ ! "$ssl" = "y" ]; then
echo ""
> $APACHE_ROOT/$dname/conf/vhost.conf
if [ "$safemode" = "y" ]; then
echo "php_admin_flag safe_mode Off"
>> $APACHE_ROOT/$dname/conf/vhost.conf
fi
if [ "$globals" = "y" ]; then
echo "php_admin_flag register_globals On"
>> $APACHE_ROOT/$dname/conf/vhost.conf
fi
echo "php_admin_value open_basedir $APACHE_ROOT/$dname/httpdocs:/tmp"
>> $APACHE_ROOT/$dname/conf/vhost.conf
echo "
" >> $APACHE_ROOT/$dname/conf/vhost.conf
vi $APACHE_ROOT/$dname/conf/vhost.conf
else
echo ""
> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
if [ "$safemode" = "y" ]; then
echo "php_admin_flag safe_mode Off"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
if [ "$globals" = "y" ]; then
echo "php_admin_flag register_globals On"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
echo "php_admin_value open_basedir $APACHE_ROOT/$dname/httpsdocs:/tmp"
>> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
echo "
" >> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
vi $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
echo "If the vhost.conf file was correct, enter "y" to activate it:"
echo -n " (y)es ->: "
read ok
if [ "$ok" = "y" ]; then
/usr/local/psa/admin/bin/websrvmng
sleep 2
if [ "$APACHE_ROOT" = "/usr/local/psa" ]; then
/usr/local/psa/rc.d/httpd restart
fi
echo "The vhost.conf file is installed and functioning."
exit 0
else
if [ "$ssl" = "y" ]; then
rm -f $APACHE_ROOT/$dname/conf/vhost_ssl.conf
else
rm -f $APACHE_ROOT/$dname/conf/vhost.conf
fi
#/usr/local/psa/admin/bin/websrvmng
echo "The vhost.conf was not activated."
fi[root@plesk httpdocs]#
Galactic Zero
did you make the script executable? Proper permissions etc.?? Not that I know what it should run as.. but that would be my guess as to the current problem.
NightStorm
vi vhost.sh
paste code
save
chmod 755 vhost.sh
sh vhost.sh
asdfqwer
NightStorm,
vi vhost.sh

First line command not found..

answered "no" to unneeded question,choosed the domain name and then

echo "" >> $APACHE_ROOT/$dname/conf/vhost_ssl.conf
vi $APACHE_ROOT/$dname/conf/vhost_ssl.conf
fi
echo "If the vhost.conf file was correct, enter "y" to activate it:"
echo -n " (y)es ->: "
read ok
if [ "$ok" = "y" ]; then
/usr/local/psa/admin/bin/websrvmng
sleep 2
if [ "$APACHE_ROOT" = "/usr/local/psa" ]; then
/usr/local/psa/rc.d/httpd restart
fi
echo "The vhost.conf file is installed and functioning."
exit 0
else
if [ "$ssl" = "y" ]; then
rm -f $APACHE_ROOT/$dname/conf/vhost_ssl.conf
else
rm -f $APACHE_ROOT/$dname/conf/vhost.conf
fi
#/usr/local/psa/admin/bin/websrvmng
echo "The vhost.conf was not activated."
fi

"vhost.sh" 68L, 2226C 68,0-1 Bot




QUOTE
Originally posted by NightStorm
vi vhost.sh
paste code
save
chmod 755 vhost.sh
sh vhost.sh
NightStorm
I take it you don't have vim editor installed on your server then.
As you can tell from the sh file I pasted, it's written to work with vim... I guess with some editing you could make it work with pico, but since I don't use that program, I can't really walk you through what to change where.
asdfqwer
Actually i have vim installed..and i have used it to paste the code and run the script but then happed what i have described above..

Any suggestions?

QUOTE
Originally posted by NightStorm
I take it you don't have vim editor installed on your server then.
As you can tell from the sh file I pasted, it's written to work with vim... I guess with some editing you could make it work with pico, but since I don't use that program, I can't really walk you through what to change where.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.