Configuration

js-cgi is configured via an INI file. This controls memory limits, execution time, error display, and which extensions are loaded.

INI File Location

The configuration file is loaded in this order (later overrides earlier):

  1. /etc/js-cgi/js-cgi.ini — system-wide
  2. js-cgi.ini in the same directory as the binary — local override
  3. --ini=/path/to/file.ini flag — takes precedence over both

Directives

memory_limit

memory_limit = 128M

Maximum memory a script can allocate. Supports K, M, G suffixes. When exceeded, the script is terminated with an error.

max_execution_time

max_execution_time = 30

Maximum execution time in seconds. When exceeded, the script is terminated with "Maximum execution time exceeded".

display_errors

display_errors = On

When On, error details and stack traces are shown in the browser. When Off, a generic error page is shown instead. Set to Off in production.

error_log

error_log = /var/log/js-cgi/error.log

Path to a file where errors are logged. Errors are always written here regardless of the display_errors setting. Also logged to stderr (which Apache captures in its error log).

extension_dir

extension_dir = /usr/lib/js-cgi/modules

Directory where extension .so files are located.

extension

extension = sqlite.so

Load an extension. Can be specified multiple times. The filename is relative to extension_dir, or can be an absolute path.

Full Example

# /etc/js-cgi/js-cgi.ini

# Resource limits
memory_limit = 128M
max_execution_time = 30

# Error handling
display_errors = Off
error_log = /var/log/js-cgi/error.log

# Extensions
extension_dir = /usr/lib/js-cgi/modules
extension = sqlite.so
extension = session.so
extension = file.so
extension = crypto.so
extension = http.so
extension = mysql.so
extension = smtp.so

Production vs Development

SettingDevelopmentProduction
display_errorsOnOff
error_log(optional)/var/log/js-cgi/error.log
memory_limit256M128M
max_execution_time6030
Was this page helpful?