ubuntu: 安装 nginx

在 ubuntu 下安装 nginx

01 更新系统

# 安装 Nginx(自动注册 systemd 服务)
sudo apt update
sudo apt install nginx -y

02 安装 nginx 并不要提示

sudo apt install nginx -y

# 检查服务是否存在
systemctl status nginx

03 添加自启动

使用 systemctl 管理

# 启动并设置开机自启
sudo systemctl start nginx
sudo systemctl enable nginx

04 查持状态

sudo systemctl enable nginx    # 开机自启
sudo systemctl start nginx     # 立即启动
sudo systemctl status nginx    # 查看状态

05 直接kill nginx

直接中止 nginx

# 先杀死旧进程
sudo pkill nginx

# 或更强制:
sudo killall nginx
nginx ubuntu systemctl