If you’re looking for a way to run PHP commands from a terminal, you’ve come to the right place. Here you’ll find all the information you need about PHP commands.
SSH is being used to access the server.
If you are a WHM Administrator, you need to access the server via SSH as root, then switch to the user with the following instructions, try to replace $username with the username that owns the script you are simply trying to execute.
su – $username -s /bin/bash
While using cPanel, ensure you have shell access first. If you have shell access, the Terminal app in cPanel will be available. Your hosting provider will need to enable the Terminal app if you haven’t already in cPanel. Log in via SSH or open the Terminal app in cPanel.
Determine the PHP version of the user.
Follow the following steps to evaluate a user’s PHP version:
WHM’s MultiPHP Manager interface
1. Log in to “WHM as root user”
2. Now search for the “Software”
3. Click on the “MultiPHP Manager”
The default PHP version of a user can be viewed and changed using this GUI. This is the most straightforward method of determining a user’s PHP version.
cPanel’s MultiPHP Manager Interface (cPanel >> Home >> Software >> MultiPHP Manager)
Go to the directory /home/username/public HTML, where “username” is the user’s username. Use this command line to run
# php — BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
# php — END cPanel-generated handler, do not edit
• Set the “ea-php73” package as the default in the above example indicates that the site is using the EasyApache PHP 7.3 supported by cPanel.
• PHP get host version is a feature in WHM API 1 that you can use.
• Make use of the UAPI feature LangPHP::php get host versions.
Find the PHP binary.
Replace the XX with the version number found in the previous step for EasyApache “ea” PHP variants:
Replace the XX with the version number found in the previous stage for CloudLinux “alt” PHP variants:
Run the script.
To begin, make sure you’re in the same directory as the script. Replace $user with the username of the script’s owner and $path with the actual path to the file’s location.
Next, make certain that you are running as the user.
Run the script, replacing the path to the PHP binary with the one found in the previous section and “script.php” with the script’s name.
- /opt/$vendor/xx-phpXX/root/usr/bin/php ./script.php
We hope that you now have a good understanding of How To Use The Terminal To Run PHP Commands. If you continue to have problems with the protocol outlined above, please contact the bodHOST Team for constructive assistance 24×7.