Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Configure PHP settings in CLI

Update 08/06/2026

This guide explains how to configure the PHP settings for web hosting directly from the command line when running PHP scripts using PHP CLI (Command Line Interface).

 

Introduction

  • This type of configuration can be useful when you need to temporarily modify certain parameters for a specific script or for a PHP session.
  • These changes will only be valid for the execution of the current script and will not modify the global PHP configuration.

 

Modify PHP CLI Settings

For example, to temporarily modify the settings for a specific script without having to modify the global PHP server configuration, follow the method below. With the PHP CLI environment, you can specify multiple PHP settings at the same time by separating them with spaces.

Using the -d parameter

When running PHP from the command line, you can use the -d parameter to specify PHP configurations. This allows you to modify PHP settings for that specific execution. For example, to set the maximum execution time to 90 seconds, the memory limit to 256 MB, and disable safe mode, you can do so as follows:

php -d max_execution_time=90 -d memory_limit=256M -d safe_mode=Off -f test.php

Has this FAQ been helpful?