• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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