When troubleshooting scripts or configuring Cron Jobs, it’s sometimes helpful to run PHP scripts via the command-line. This guide will walk you through the steps to run a PHP script in the terminal in cPanel.
Prerequisites
Before you begin, make sure you have the following:
- An Ecenica plan with terminal access.
- A PHP script that you wish to run.
Steps to Run a PHP Script in Terminal
Log in into cPanel
For help logging in to cPanel see Where do I login to my hosting control panel
Step 2: Open Terminal
Once you’re logged in, scroll down to the Advanced
section and click on the Terminal
icon.
Step 3: Navigate to the PHP Script
In the terminal, use the cd
command to navigate to the directory where your PHP script is located. For example, if your script is in the public_html
directory, you would type:
cd public_html
Step 4: Run the PHP Script
Now that you’re in the correct directory, you can run your PHP script. Use the php
command followed by the name of your script. For example, if your script is named script.php
, you would type:
php script.php
Your script should now run, and any output will be displayed in the terminal.