FS-Cli常用命令简介

目录

退出操作

日志与显示操作

全局变量

fsctl:发送控制信息

通话相关命令简介

show:显示信息


fs_cli是FreeSWITCH的一个客户端连接程序,可以方便地查看运行情况,并对其进行控制。若在本机使用默认配置,可直接启动fs_cli;否则需要携带参数(以连接运行在192.168.1.100上的FreeSWITCH为例):

  • 启动一个命令行窗口,通过help可以查看操作命令;

fs_cli.exe -H 192.168.1.100 -P 8021 -p NewPSW  

  • fs_cli也可执行一条指定的命令(如获取版本信息):

fs_cli.exe -H 192.168.1.100 -P 8021 -p NewPSW   -x "version"

 

以下‘Console窗口‘是指通过命令行启动(不用nc参数)时的显示与控制界面。

 


退出操作

退出fs_cli(保持FreeSWITCH运行):

  • /quit

  • /bye

  • /exit

  • ...:三个点,若在‘Console窗口‘中为退出FreeSWITCH;

  • Linux可通过ctrl+D快捷键;

退出FreeSWITCH:

  • shutdown

 


日志与显示操作

设定显示日志级别

  • 通过console loglevel设定显示级别(fs_cli和‘Console窗口‘中都可以):

    • debug,info,notice,warning,err,crit,alert:7个级别

    • 1~7: 对应上面7个级别(7为debug,1为alert)

    • 0:关闭所有输出(console loglevel 0);

  • fsctl loglevel <level>:设定指定日志级别;

  • /log:默认为debug或指定的级别(与loglevel相同);

  • /nolog:关闭日志;

  • sofia profile internal siptrace  on/off:开启或关闭SIP消息跟踪功能。

 


全局变量

  • 全局变量:

    • global_getvar [<varname>]:获取全局变量

    • global_setvar <varname>=<value>:设定全局变量

  • 查看:eval ${val-name}

global_getvar domain

eval ${domain}

 


fsctl:发送控制信息

fsctl [send_sighup |

        hupall |

        pause [inbound|outbound] |

        resume [inbound|outbound] |

        shutdown [cancel|elegant|asap|restart] |

        last_sps |

        sps [num] |

        sync_clock |

        sync_clock_when_idle |

        reclaim_mem |

        max_sessions |

        min_dtmf_duration [num] |

        max_dtmf_duration [num] |

        default_dtmf_duration [num] |

        loglevel [level] |

        verbose_events [on|off]

       ]

  • fsctl debug_level [level]:设定日志记录级别(影响日志记录、console输出等)

    • 0 - fatal errors, panic

    • 1 - critical errors, minimal progress at subsystem level

    • 2 - non-critical errors

    • 3 - warnings, progress messages

    • 5 - signaling protocol actions (incoming packets, ...)

    • 7 - media protocol actions (incoming packets, ...)

    • 9 - entering/exiting functions, very verbatim progress

  • fsctl hupall <clearing_type> dialed_ext <extension>:关闭所有指定呼叫,如:fsctl hupall normal_clearing dialed_ext 1000

  • fsctl shutdown [asap|asap restart|cancel|elegant|now|restart|restart asap|restart elegant]

    • cancel - discontinue a previous shutdown request.

    • elegant - wait for all traffic to stop, while allowing new traffic.

    • asap - wait for all traffic to stop, but deny new traffic.

    • now - shutdown FreeSWITCH immediately.

    • restart - restart FreeSWITCH immediately following the shutdown.

 


通话相关命令简介

  • 查看注册用户:

    • sofia status/xmlstatus profile internal reg [1006]

    • show registrations

  • 删除注册用户:sofia profile internal flush_inbound_reg <用户id>

  • 查看通话通道:show channels [like 1006@] as xml

  • 呼叫(1.6版本下,要带absolute_codec_string='PCMA',否则可能是视频呼叫,然后编码失败):

    • originate user/1011 &bridge(user/1013)

    • originate user/1006 &bridge(sofia/external/5001@192.168.6.90)

    • originate user/1011 &playback(rec1011.wav)

    • originate user/1012 &conference(3001)

    • originate user/1011 &echo

  • 关闭所有指定呼叫:hupall <cause> [<variable> <value>]

    • hupall normal_clearing foo bar:关闭所有通道变量foo=bar的channel

  • 加入会议:

    • conference 3001 dial {absolute_codec_string='PCMA@20i'}user/1013

    • conference 3001 dial sofia/external/5001@192.168.6.90

    • 列出所有会议:conference list

  • 呼叫中心:

    • 查看Agent:callcenter_config agent list 

    • 查看队列:callcenter_config queue list

  • 顺振:originate user/1006 &bridge(user/1011|user/1012)

  • 同振:originate user/1006 &bridge(user/1011,user/1012)

  • 添加通道变量:originate {origination_caller_id_number=8888,ignore_early_media=true,xugd-wavfile=notice.wav,absolute_codec_string=PCMA}user/1018 &lua(voiceNotify.lua) 

  • 重新加载配置:

    • reloadxml:重新一般配置修改(拨号计划、用户等)

    • 网关(重启):sofia profile external restart

    • 只重新加载修改的网关(gwt):

      • sofia profile external killgw gwt

      • sofia profile external rescan

    • reload <mod_name>:重新加载模块

    • reloadacl:重新加载ACL

  • uuid一族(以uuid开始的)

    • uuid_answer <uuid>:接听

    • uuid_kill <uuid> [cause]:挂机

    • uuid_bridge <uuid> <other_uuid>:桥接通道

    • uuid_transfer <uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>]:转移电话

    • uuid_break <uuid> [all]:停止媒体发送

    • uuid_broadcast <uuid> <path> [aleg|bleg|both]:播放媒体;

    • uuid_deflect <uuid> <sip URL>:转移通话

    • uuid_displace <uuid> [start|stop] <file> [<limit>] [mux]:替换媒体(Displace the audio for the target with the specified audio)

    • uuid_record <uuid> [start|stop|mask|unmask] <path> [<limit>]:录音,Where limit is the max number of seconds to record

    • uuid_getvar <uuid> <varname>:获取通道上变量

    • uuid_setvar <uuid> <varname> [value]:设定通道变量

 


show:显示信息

show [

   aliases |

   api |

   application |

   bridged_calls |

   calls [count] |

   channels [count|like <match string>] |

   chat |

   codec |

   complete |

   detailed_bridged_calls |

   detailed_calls |

   dialplan |

   endpoint |

   file |

   interface_types |

   interfaces |

   limits

   management |

   modules |

   nat_map |

   registrations |

   say |

   tasks |

   timer |

   ] [as xml|as delim <delimiter>]

  • aliases – list defined command aliases

  • api – list api commands exposed by loadable modules

  • application – list applications exposed by loadable modules, notably mod_dptools

  • calls [count] – list details of currently active calls; the keyword "count" eliminates the details and only prints the total count of calls

  • channels [count|like <match string>] – list current channels; see Channels vs Calls

    • count – show only the count of active channels, no details

    • like <match string> – filter results to include only channels that contain <match string> in uuid, channel name, cid_number, cid_name, presence data fields.

  • chat – list chat interfaces

  • codec – list codecs that are currently loaded in FreeSWITCH

  • complete – list command argument completion tables

  • detailed_bridged_calls – same as "show detailed_calls"

  • detailed_calls – like "show calls" but with more fields

  • dialplan – list dialplan interfaces

  • endpoint – list endpoint interfaces currently available to FS

  • file – list supported file format interfaces

  • interface_types – list all interface types with a summary count of each type of interface available

  • interfaces – enumerate all available interfaces by type, showing the module which exposes each interface

  • limits – list database limit interfaces

  • management – list management interfaces

  • module – enumerate modules and the path to each

  • nat_map – list Network Address Translation map

  • registrations – enumerate user extension registrations

  • say – enumerate available TTS (text-to-speech) interface modules with language supported

  • tasks – list FS tasks

  • timer – list timer modules

<think>好的,用户现在想了解如何使用WP-CLI配置WordPress网站的建站配置文件。首先,我需要确认用户对WP-CLI的了解程度。WP-CLI是命令行工具,可能用户已经安装好了,但需要具体步骤来配置。 用户可能是在搭建新站点,或者需要自动化配置,比如在Docker环境中或批量部署。这时候,使用WP-CLI可以节省时间,避免手动操作。用户提到的“建站配置文件”可能指的是wp-config.php,这是WordPress的核心配置文件,包含数据库连接信息和其他设置。 首先,我需要回忆如何使用WP-CLI生成wp-config.php。通常,安装WordPress时会提示输入数据库信息,但通过WP-CLI可以用命令生成。可能需要检查用户是否已经下载了WordPress文件,或者是否需要从头开始安装。 然后,配置数据库连接的部分。需要包括数据库名称、用户名、密码、主机和前缀。用户可能需要自定义这些参数,特别是如果他们在共享主机或有特定安全要求的情况下。 接下来是配置其他常用参数,比如调试模式、安全密钥、语言设置等。这些设置对于开发环境和生产环境都很重要,用户可能需要根据具体情况调整。例如,开启WP_DEBUG在开发中很有用,但在生产环境中应该关闭。 自动生成安全密钥也是一个重点,因为这增强了网站的安全性。用户可能不知道如何手动生成这些密钥,所以使用WP-CLI的选项会更方便。 另外,用户可能想设置站点的URL,这在迁移网站或更改域名时很重要。需要提醒用户正确设置这两个值,否则可能导致网站无法访问。 还有一些高级配置,比如内存限制、文件权限、自动更新等。这些可能根据用户的服务器环境有所不同,需要提供示例命令,并说明适用情况。 最后,用户可能需要验证配置文件是否正确,或者需要其他操作,比如安装WordPress核心或插件。这时候可能需要分步骤说明,或者给出完整的自动化脚本示例。 需要注意的是,用户可能是在自动化部署脚本中使用这些命令,比如结合Docker或CI/CD流程。因此,提供清晰、可复制的命令示例很重要,同时提醒注意事项,比如权限问题、路径是否正确等。 可能用户遇到的问题包括命令执行权限不足,或者数据库连接失败。因此,在注意事项中强调检查权限和验证配置是正确的,避免常见错误。 总结来说,需要分步骤介绍生成配置文件、配置数据库、其他设置、高级配置,并给出完整示例和注意事项,确保用户能够顺利使用WP-CLI完成WordPress的配置。</think>以下是使用 **WP-CLI** 配置 WordPress 网站核心配置文件(`wp-config.php`)的详细指南: --- ### 一、核心配置文件生成与配置 #### 1. **生成 `wp-config.php` 文件** 如果尚未创建 WordPress 配置文件,可通过以下命令直接生成: ```bash wp config create --dbname=数据库名 --dbuser=用户名 --dbpass=密码 --dbhost=数据库主机 --dbprefix=表前缀_ --locale=语言代码 ``` - **参数说明**: - `--dbname`: 数据库名称(如 `wordpress`) - `--dbuser`: 数据库用户名(如 `root`) - `--dbpass`: 数据库密码(如 `secure_password`) - `--dbhost`: 数据库主机地址(默认 `localhost`,Docker 环境可能为 `db:3306`) - `--dbprefix`: 数据表前缀(建议自定义,如 `wp_custom_` 提升安全性) - `--locale`: 语言代码(如 `zh_CN` 表示简体中文) **示例**: ```bash wp config create --dbname=wp_site1 --dbuser=admin --dbpass=P@ssw0rd --dbhost=127.0.0.1 --dbprefix=wp_abc_ --locale=zh_CN ``` #### 2. **修改已有配置** 通过 `wp config set` 直接更新配置项(无需手动编辑文件): ```bash wp config set 常量名 值 --type=类型 ``` - **常用操作**: ```bash # 开启调试模式(开发环境) wp config set WP_DEBUG true --raw # 设置站点URL(需与数据库中的域名一致) wp config set WP_HOME 'https://example.com' wp config set WP_SITEURL 'https://example.com' # 配置自动更新策略 wp config set WP_AUTO_UPDATE_CORE true --raw # 自定义安全密钥(自动生成) wp config set AUTH_KEY "$(wp config generate-salts 2>&1 | grep AUTH_KEY | cut -d\' -f4)" ``` --- ### 二、完整建站自动化脚本示例 可结合以下命令实现从安装到配置的全流程自动化: ```bash # 下载 WordPress 核心文件 wp core download --locale=zh_CN # 生成配置文件 wp config create --dbname=wp_demo --dbuser=wp_user --dbpass=secret --dbhost=db --locale=zh_CN # 安装 WordPress(自动创建数据库表) wp core install --url=https://example.com --title="我的网站" --admin_user=admin --admin_password=Admin@123 --admin_email=admin@example.com # 配置调试模式和安全密钥 wp config set WP_DEBUG true --raw wp config shuffle-salts # 设置文件权限(防止写冲突) wp config set FS_METHOD direct --raw ``` --- ### 三、高级配置命令 #### 1. **多环境配置** 通过 `--config` 指定不同环境的配置文件: ```bash wp config set ENVIRONMENT production --type=constant --config=wp-config-prod.php ``` #### 2. **内存限制调整** ```bash wp config set WP_MEMORY_LIMIT '256M' --type=constant ``` #### 3. **禁用文件编辑** ```bash wp config set DISALLOW_FILE_EDIT true --raw ``` --- ### 四、注意事项 1. **权限要求**:确保运行 WP-CLI 的用户对 WordPress 目录有写入权限 2. **路径验证**:在 WordPress 根目录下执行命令(可通过 `wp --info` 检查路径) 3. **安全建议**: - 避免在命令行历史中暴露密码(可改用环境变量) - 生产环境关闭 `WP_DEBUG` 和 `SCRIPT_DEBUG` 4. **配置验证**:通过 `wp config get` 检查配置项是否生效 ```bash wp config get WP_DEBUG # 输出当前调试模式状态 ``` --- 如果需要补充特定场景的配置(如 Docker 集成、HTTPS 强制跳转等),请进一步说明需求!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值