Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

linux 安装 nginx

作者:淡漠伤悲   发布日期:2026-07-21   浏览:83

# 更新软件包列表
sudo apt update

# 安装 Nginx
sudo apt install nginx

# 启动 Nginx 服务
sudo systemctl start nginx

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

# 检查 Nginx 是否正在运行
sudo systemctl status nginx

# 配置防火墙以允许 HTTP 和 HTTPS 流量
sudo ufw allow 'Nginx Full'

# 查看 Nginx 默认页面(确保安装成功)
curl http://localhost

解释说明:

  1. 更新软件包列表:使用 apt update 命令来更新本地的软件包列表,确保获取最新的软件包信息。
  2. 安装 Nginx:通过 apt install nginx 安装 Nginx。
  3. 启动 Nginx 服务:使用 systemctl start nginx 启动 Nginx 服务。
  4. 设置 Nginx 开机自启动:通过 systemctl enable nginx 设置 Nginx 在系统启动时自动启动。
  5. 检查 Nginx 状态:使用 systemctl status nginx 检查 Nginx 服务的状态,确保它正在运行。
  6. 配置防火墙:使用 ufw allow 'Nginx Full' 允许 HTTP 和 HTTPS 流量通过防火墙。
  7. 查看默认页面:使用 curl http://localhost 查看 Nginx 的默认欢迎页面,确认安装成功。

上一篇:linux复制文件夹到指定目录

下一篇:linux 重命名文件

大家都在看

linux如何启动nginx

linux常用命令查询端口是否正常

linux 发送邮件

linux长ping命令

linux groupadd

linux关机命令行

linux 安装 gcc

linux重启oracle命令

linux把一个文件夹移动到另一个文件夹里

linux删除docker

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站