Writing custom PHP script for cPanel interface
cPanel allows for additional pages to be written in PHP rather than straight HTML. This provides full access to cPanel APIs. Please read API tags for more information about API.
To use cPanel PHP, place a PHP script anywhere inside of the following directory:
/usr/local/cpanel/base/frontend/file_name
You can access the directory at in the following way:
http://www.example.com:2082/frontend/file_name
Extention specific execution:
- .php — Executes cPanel tags before the PHP code
- .cpphp — Executes cPanel tags before the PHP code
- .phpcp — Executes the PHP code followed by the cPanel tags.
Important Notes:
- Please note that placing the script outside of this directory will cause the source code to be exposed.
- cPanel tags are still available by using <cpanel> and <?cp> tags. These tags can be executed before or after the PHP script. The order of execution is determined by the above described file extension used.
- cPanel PHP files should never use the short opening tag for PHP, <?php should be used instead.