# Alpine Linux 确定 nginx 是否在运行

**URL:** <https://www.isharkfly.com/t/alpine-linux-nginx/15748>\
**Category:** DevOps\
**Tags:** linux\
**Created:** [May 14, 2024, 9:40pm UTC](https://www.isharkfly.com/t/alpine-linux-nginx/15748 "2024-05-14T21:40:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [May 14, 2024, 9:40pm UTC](https://www.isharkfly.com/t/alpine-linux-nginx/15748/1 "2024-05-14T21:40:37Z")

</div>

确定进程在 Linux 中是否运行，主要看进程是否在运行和端口是否被占用。

不同的操作系统的命令也会有一些不一样。

针对 Alpine 操作系统。

## 查看进程

查看 nginx 进程是否在运行的命令为：

```bash
ps aux | grep "[n|N]ginx"

```

服务器输出为：

```bash
/ # ps aux | grep "[n|N]ginx"
  169 root 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
  170 nginx 0:00 nginx: worker process
  171 nginx 0:00 nginx: worker process
  172 nginx 0:00 nginx: worker process
  173 nginx 0:00 nginx: worker process
  174 nginx 0:00 nginx: worker process
  175 nginx 0:00 nginx: worker process
  177 nginx 0:00 nginx: worker process
  178 nginx 0:00 nginx: worker process
  180 nginx 0:00 nginx: worker process
  181 nginx 0:00 nginx: worker process
  183 nginx 0:00 nginx: worker process
  184 nginx 0:00 nginx: worker process
  186 nginx 0:00 nginx: worker process
  188 nginx 0:00 nginx: worker process
  190 nginx 0:00 nginx: worker process
  191 nginx 0:00 nginx: worker process
/ #
/ #

```

 ![2024-05-14_17-38-08](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/2X/9/9b62b317eac4fb295ecb83445d8899b36a240eea.png)

## 查看端口是否被占用

nginx 通常使用的是 80 端口。

所以我们可以使用下面的命令查看下 80 端口有没有被占用：

```bash
netstat -tulpn | grep :80

```

服务器针对上面命令的输出为：

```bash
/ # netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 169/nginx.conf
tcp 0 0 :::80 :::* LISTEN 169/nginx.conf
/ #

```

 ![2024-05-14_17-39-56](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/2X/0/0f901d8be87855d43fa02a7af4b75d089558251c.png)

通过上面的方法，我们可以确定下进程有没有起来。
