• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Give php script root permission

bob231

Basic Pleskian
Good day!

What is the most easy way to give a single php script of vhost root permissions?
I want to restart mysql by a php script:

$cmd = "sudo /var/www/vhosts/default/optimize_db.sh";
exec($cmd, $output, $retval);
echo $retval;

In optimize_db.sh i have:

service mysqld stop
/usr/bin/myisamchk -arS /var/lib/mysql/*/*.MYI
service mysqld start


Hope someone knows how to change the permissions so this is gonna work!
Thanks, Bob
 
I have try by edit /etc/sudoers i give apache all rights wiht nopassword but it doesn't work.
I use a VPS, installed software plesk 8.6 centos 5 x86_64, please someone can help me?
 
I'd solve this completely outside of any vhost context and just use a one line bash script (and run it using root's crontab if you want to run it on a schedule).

#!/bin/sh
# Optimize all databases

mysqlcheck --optimize --all-databases --user=admin --password=`cat /etc/psa/.psa.shadow`

You really don't want to give apache root permissions and using this there's also no need to stop MySQL.
 
You could also create a php file that calls the Plesk API that will restart any service you want, and then password protect the flie/directory. that is much more secure
 
How to give full permission to apache server by sudoers

i want to run some services by a php script,so i have to give permission to apache .

i have tried in sudoers file ,like this-

apache ALL=(root) NOPASSWD: /home/svsystems/bin/failover.pl
apache ALL=(root) NOPASSWD: /etc/init.d/tmanagerd
apache ALL=(root) NOPASSWD: /etc/init.d/fxjobupdate
apache ALL=(root) NOPASSWD: /etc/init.d/errdbflush
apache ALL=(root) NOPASSWD: /etc/init.d/setresync

and this also

User_Alias APACHE = wwwrun
Cmnd_Alias TMANAGER = /etc/init.d/tmanagerd, /home/svsystems/bin/failover.pl, /etc/init.d/fxjobupdate, /etc/init.d/errdbflush, /etc/init.d/setresync
APACHE ALL = (ALL) NOPASSWD: TMANAGER
wwwrun ALL=/home/svsystems/bin/failover.pl ALL
wwwrun ALL=/etc/init.d/tmanagerd ALL
wwwrun ALL=/etc/init.d/fxjobupdate ALL
wwwwrun ALL=/etc/init.d/errdbflush ALL
wwwrun ALL=/etc/init.d/setresync ALL





These are not working,help me if there is any other way by sudoers or something else
 
Back
Top