# 安装 Nginx
# 更新软件包索引
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 配置文件
sudo nano /etc/nginx/sites-available/default
# 示例配置文件内容:
server {
listen 80;
server_name your_domain_or_IP;
location / {
root /var/www/html;
index index.html index.htm;
}
# 其他配置项...
}
# 测试 Nginx 配置文件语法是否正确
sudo nginx -t
# 重新加载 Nginx 以应用更改
sudo systemctl reload nginx
apt 包管理器安装 Nginx。上一篇:linux命令行查看网络状态
下一篇:linux杀掉进程
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站