温馨提示×

centos中postman配置方法

小樊
85
2025-03-17 11:16:27
栏目: 智能运维

在CentOS系统中配置Postman主要有两种方式:通过命令行使用newman工具或在图形界面中直接安装Postman应用程序。以下是详细的步骤:

通过命令行使用newman工具配置Postman

  1. 安装Node.js和npm
  • 下载并安装Node.js和npm(Node包管理器)。
wget https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz
tar -xf node-v16.15.1-linux-x64.tar.xz -C /usr/local/
mv node-v16.15.1-linux-x64 node0
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
  1. 安装newman
  • 使用npm全局安装newman命令行工具。
npm install -g newman
  1. 配置和使用newman
  • 创建并运行Postman的集合(collection)和请求(request)。可以使用newman命令行工具来执行这些操作。
newman run your-collection.json

在图形界面中安装Postman应用程序

  1. 下载Postman安装包
  1. 解压安装包
  • 使用tar命令解压下载的安装包到指定目录。
tar zxvf Postman-linux-x64-*.tar.gz -C /usr/local/
  1. 建立软链接
  • 为解压后的Postman可执行文件创建软链接,以便在任意目录下都能使用postman命令。
sudo ln -s /usr/local/Postman/Postman /usr/bin/postman
  1. 创建Postman应用程序启动器(可选,适用于Gnome环境):
  • 创建一个桌面快捷方式,方便从应用程序菜单启动Postman。
sudo touch /usr/share/applications/postman.desktop
sudo vim /usr/share/applications/postman.desktop

/usr/share/applications/postman.desktop文件中添加以下内容:

[Desktop Entry]
Encoding=UTF-8
Name=Postman
GenericName=API Tools
Comment=Postman
Exec=/usr/bin/postman
Terminal=false
MimeType=text/plain
Icon=/usr/local/Postman/Postman/app/resources/app/assets/icon.png
StartupNotify=true
Categories=Development;
  1. 启动Postman
  • 通过命令行或图形界面启动Postman应用程序。
postman

或者从应用程序菜单中找到Postman并点击启动。

以上就是在CentOS系统中配置Postman的两种主要方法。根据你的需求和偏好,可以选择使用命令行工具newman或者安装图形界面的Postman应用程序。

0