Question
How do you run PHP commands as a cPanel user via the Terminal?
Answer
When troubleshooting scripts, it is often necessary to run PHP scripts via the command line. This article provides the procedure to run a PHP script using the same PHP version that the user's site uses.
- Log in to the cPanel user's cPanel.
- Open the MultiPHP Manager interface in the Software section of cPanel.
- Note the PHP version used by the site.
- Click the Tools link from the left-side menu.
- Open the Terminal interface in the Advanced section of cPanel.
- Read the warning and click the I understand and want to proceed. button.
Change to the directory that the script is in by running the following command:
# cd /home/$username/path/to/script/folder
Note: "/home/$username/path/to/script/folder" must be replaced with the full path to the script's folder.
Execute the script using the full path to the
phpexecutable:ea-php# /opt/cpanel/ea-phpXX/root/usr/bin/php script.php
Note: "XX" and "script.php" must be replaced with the PHP version (without the decimal point) and the script's file name, respectively.
alt-php# /opt/cloudlinux/alt-phpXX/root/usr/bin/php script.php
Note: "XX" and "script.php" must be replaced with the PHP version (without the decimal point) and the script's file name, respectively.
Comments
0 comments
Article is closed for comments.