Home > other >  Call php file in cpanel
Call php file in cpanel

Time:12-22

I'm trying to call an example php file "example.php" that return "Hello world" to test some functionality in my app.

When i call URL: "http://www.example.com:2083/home/public_html/example.php" the server redirect to cpanel access page. So, after some google resources, i've generated an API TOKEN through cpanel API token manager and i've tried to call this file using curl like this: "curl -H "Authorization: cpanel username:API_TOKEN" "https://www.example.it:2083/execute/home/public_html/example.php" but always retrive this message: {"metadata":{},"data":null,"errors":["Illegal function name:public_html/example.php"],"warnings":null,"messages":null,"status":0}".

Is this the right way to call a php file hosted on cpanel? Thanks for any help :)

CodePudding user response:

Looks like you are calling the file wrong way.

  1. The port after your website ":2083" will forward you towards the cpanel.
  2. You do not need to put the whole directory "/home/public_html" to call it, since your domain name itself points you towards "public_html"'s "index" directory.

Taking this URL are reference: http://www.example.com:2083/home/public_html/example.php

The correct way to call it would simply be: http://www.example.com/example.php

  • Related