• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

How to access plesk 11 cli tools from Webscripts (correctly) ?

cts-service

New Pleskian
Hi,

I have a private Admin-Webspace written in PHP to do some Server Tasks with shell exec functions.

The Webuser is running under fastcgi permissions.
I put him into /etc/sudoers
Then I enabled the function: Users can use their own webscripts for this particular domain and shell access to bash.

Logging in with ssh as user ftp_user and executing the shell admin script from terminal is no problem at all!

But using the browser, opening the php script and then doing a shell exec always throws me an error.


To make it clear, here a snippet (just example):
creating /var/www/vhosts/domain.com/adminpanel/test.php

test.php:
Code:
#!/bin/bash

KD_DB_PW="ihg45kjbOJGoghigb456ojojbn"
PLESK_PATH="/usr/local/psa/bin/"
DB_USER="test"

PSA_PASSWORD='As45fgIpvi45fgtj2'


echo "setting up hosting";

echo "creating user";

sudo -i -uroot $PLESK_PATH/./customer --create "$DB_USER" \
	-name "Plesk User: $DB_USER" -passwd "$DB_PW" \
	-notify false -owner pleskadmin ' '

The Plesk admin environment variable, how do I use it in scripts?
I always get the error:
Code:
Could not open Repository at "/etc/sw/keys": Cannot open file
Unable to connect to database: get_admin_password() failed: file_get_contents() failed:
 
Last edited:
Back
Top