Menu

Configuration management

This article was last updated 37 days ago, please note whether the content is still available

Configuration File

After properly installing Z-BlogPHP, a configuration file will be generated at a path such as path/zb_users/c_option.php, recording basic information such as database connection details; when performing operations like space migration, database replacement, etc., you may need to manually modify this file to complete the operation.

path:The path where the current blog program is placed, for example /home/wwwroot/www.zblogcn.com

Admin Login

host/zb_system/cmd.php?act=login will redirect to: host/zb_system/login.php

host:The URL path used to access via browser, for example https://www.zblogcn.com/

You can manage the site in the Site Settings option;

Important:Site Settings→Global Settings→Development Mode ←This option can be enabled to troubleshoot when the site shows error prompts;

Composer Install PHP Packages

Since Z-BlogPHP version 1.7.2, the system can automatically load packages from the vendor directory

So you only need to install composer packages into verndor, you do not need to include the autoload.php file under vendor

Create c_option.php first, then run the installation process (supported since 1.7.2)

Usually after the installer completes, the c_option.php configuration file is automatically generated in the zb_users directory

How to pre-configure c_option.php before running the installation process?

You need to add 'ZC_INSTALL_AFTER_CONFIG' => true to a newly created file c_option.php, then fill in other database configurations, so when you open the site it will automatically transfer to the installation page to perform the installation process (assuming the database configuration is correct and can connect).

// c_option.php 示例如下
return array (
  'ZC_INSTALL_AFTER_CONFIG' => true,
  'ZC_DATABASE_TYPE' => 'mysqli',
  'ZC_MYSQL_SERVER' => 'localhost',// 数据库地址
  'ZC_MYSQL_USERNAME' => '账号名',
  'ZC_MYSQL_PASSWORD' => '账号密码',
  'ZC_MYSQL_NAME' => '数据库名',
  'ZC_MYSQL_CHARSET' => 'utf8mb4',
  'ZC_MYSQL_COLLATE' => 'utf8mb4_general_ci',
  'ZC_MYSQL_PRE' => 'zbp_',
  'ZC_MYSQL_ENGINE' => 'MyISAM',
  'ZC_MYSQL_PORT' => '3306',// 数据库端口号
  'ZC_MYSQL_PERSISTENT' => false,
);

Reading Database Configuration from Environment Variables

The values of parameters in the c_option.php configuration file are Zbp_GetEnv('ENV_VAR_NAME'), which will read the environment variable value using the Zbp_GetEnv function (supported since 1.7.3)

// c_option.php 示例如下
<?php
return array (
  'ZC_DATABASE_TYPE' => 'mysqli',
  'ZC_MYSQL_SERVER' => Zbp_GetEnv('DB_HOST'),// environment variable name
  'ZC_MYSQL_USERNAME'= => Zbp_GetEnv('DB_USER'),// environment variable name
  'ZC_MYSQL_PASSWORD'=> Zbp_GetEnv('DB_PASSWORD'),// environment variable name
  'ZC_MYSQL_NAME'=> Zbp_GetEnv('DB_DATABASE'),// environment variable name
  'ZC_MYSQL_PORT'= &39;3306',
  'ZC_MYSQL_CHARSET'= 'utf8mb4',
  'ZC_MYSQL_COLLATE'= 'utf8mb4_general_ci',
  'ZC_MYSQL_PRE'= 'zbp_',
  'ZC_MYSQL_ENGINE'= 'MyISAM',
  'ZC_MYSQL_PERSISTENT' => false,
);

Then the values of ZC_MYSQL_SERVER, ZC_MYSQL_USERNAME, ZC_MYSQL_PASSWORD, ZC_MYSQL_NAME will be obtained from Zbp_GetEnv('DB_HOST') etc.

Note:

Zbp_GetEnv function was added in 1.7.3, and Zbp_GetEnv calls the Get method of the ZbpEnv class; the Get method will fetch environment variables in the order of $_ENV, getenv

The ZbpEnv class automatically loads the .env file during initialization (if it exists) and adds the configurations and values from the .env file to the environment variables. If you place and use a .env file in the system root directory, please make sure to protect this file from web downloads to avoid accidental risk

Note 2:

Version 1.7.2 and above can also fill in env:DB_HOST, env:DB_USER, env:PASSWORD, env:DB_DATABASE to obtain environment variable values

  //示例如下:
  'ZC_MYSQL_SERVER' => 'env:DB_HOST'// environment variable name: DB_HOST
  'ZC_MYSQL_USERNAME' = 'env:DB_USER'// environment variable name: DB_USER
  'ZC_MYSQL_PASSWORD' = 'env:DB_PASSWORD'// environment variable name: DB_PASSWORD
  'ZC_MYSQL_NAME' = 'env:DB_DATABASE'// environment variable name: DB_DATABASE

Other versions can also obtain environment variable values via the getenv function

Helpful?

Comments(2)

剑影飞鸿
剑影飞鸿

2025-10-09 22:19:32

详细介绍了Z-BlogPHP的配置文件、后台登录、Composer安装包、安装过程优化和环境变量配置等操作步骤。
剑影无痕
剑影无痕

2025-10-09 13:23:37

详尽介绍了Z-BlogPHP的配置文件操作、后台登录路径、Composer安装包以及c_option.php文件配置的多种方法。

Post comment

Support Live Chat
TOP