ubuntu中如何查看是否已经安装了nginx

在 Ubuntu 系统中,可以通过以下几种方法检查是否已安装 Nginx


方法 1:使用 dpkg 命令(适用于 Debian/Ubuntu)

perl 复制代码
bash
dpkg -l | grep nginx
  • 输出示例

    bash 复制代码
    ii  nginx                       1.18.0-0ubuntu1   all          small, powerful, scalable web/proxy server
    ii  nginx-common                1.18.0-0ubuntu1   all          small, powerful, scalable web/proxy server - common files
  • 说明

    • 如果已安装,会显示 Nginx 的版本和状态(ii 表示已安装且正常)。
    • 如果未安装,无输出或提示 No packages found matching nginx

方法 2:检查 Nginx 服务状态

lua 复制代码
bash
systemctl status nginx

或(旧版 Ubuntu 使用 service 命令):

lua 复制代码
bash
service nginx status
  • 输出说明

    • 已安装 :显示服务状态(active (running)inactive (dead))。
    • 未安装 :提示 Unit nginx.service not foundnginx: unrecognized service

方法 3:直接运行 nginx 命令

复制代码
bash
nginx -v

或查看详细版本信息:

复制代码
bash
nginx -V
  • 输出说明

    • 已安装 :显示版本号(如 nginx version: nginx/1.18.0)。
    • 未安装 :提示 Command 'nginx' not found
相关推荐
Warson_L15 分钟前
Python 流程控制与逻辑
后端·python
糖炒栗子032617 分钟前
架构笔记:应用配置无状态化 (Statelessness)
后端
Warson_L24 分钟前
Python 四大组合数据类型 (Collection Types)
后端·python
查古穆1 小时前
大白话讲ReAct:大模型的“边想边干”
后端
于先生吖1 小时前
SpringBoot+MQTT 无人健身房智能管控系统源码实战
java·spring boot·后端
毕设源码-小云学姐1 小时前
计算机毕业设计springboot网上招聘系统 基于SpringBoot的在线人才对接平台设计与实现 SpringBoot框架下的数字化求职招聘服务系统开发
spring boot·后端·课程设计
weyyhdke3 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
ywf12153 小时前
Go基础之环境搭建
开发语言·后端·golang
Victor3563 小时前
MongoDB(76)如何配置防火墙规则?
后端
Victor3563 小时前
MongoDB(75)如何配置TLS/SSL加密?
后端