This article explains how to specify a specific PHP version for a scheduled task on a Hostek website. This is necessary when a task requires a different PHP version than the one used by the primary website.
Before you begin
You will need:
A Hostek account with access to the hosting control panel (such as cPanel or Windows Control Panel).
The specific PHP version required by your application or script.
Selecting the PHP Version for a Scheduled Task
The method for selecting the PHP version depends on the control panel and environment your website uses.
For cPanel Users
If your account uses cPanel, you can specify the PHP version for a specific script or task by using a .user.ini or .ini file within the directory where the task is executed.
Log in to your cPanel account.
Open the File Manager.
Navigate to the directory where the script or task is located.
Create or edit a file named
.user.ini(or.inidepending on your specific server configuration).Add the following line to the file, replacing the version with your desired PHP version:
; Set the PHP version for this directoryphp_value[_PHP_VERSION] = 8.x
Note: The exact syntax may vary based on the specific PHP handler used by your account. If you are unsure of the correct syntax for your specific version, contact Hostek support for the exact line to include.
For Windows Control Panel (WCP) Users
If your account uses the Windows Control Panel, scheduled tasks are often managed via the Windows Task Scheduler or through specific application configurations.
Log in to the Windows Control Panel.
Navigate to the Application Manager or the specific application's configuration area.
Locate the configuration settings for the specific service or task.
Select the desired PHP Version from the available options.
Click Save or Update.
Confirm the result
To verify that the task is using the correct PHP version, you can create a temporary information script.
Create a file named
info.phpin the directory where the task runs.Add the following code to the file:
<?php phpinfo(); ?>
Execute the scheduled task or visit the
info.phpURL (if applicable) to view the PHP version details.Confirm that the PHP Version listed matches your selection.
Warning: Delete the
info.phpfile immediately after confirming the version to ensure your site remains secure.
Limitations
This procedure only applies to tasks that are configured to run within the context of a specific directory.
If a task is executed via a system-level cron job that does not point to a specific directory, it may default to the system's primary PHP version.
Some third-party applications may have their own internal settings that override these configurations.
