Nginx使用

呆呆的猪胖胖 Lv4

前言

web开发服务器有很多选择,Nginx作为其中之一,作者本人还是经常使用的,最近刚好需要重新配置Nginx
因此决定写一个使用的教程。

安装与启动

  1. 更新软件包依赖(可选)

    1
    sudo apt update
  2. 安装nginx

    1
    sudo apt install nginx
  3. 启动nginx

    1
    sudo systemctl start nginx
  4. 设置开机自启动

    1
    sudo systemctl enable nginx
  5. 检测nginx运行状态

    1
    sudo systemctl enable nginx

接下来,只需要打开本地IP:80即可查看到nginx的欢迎页面。

注:使用yum安装包的安装命令

1
2
3
4
5
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl enable nginx

配置

进行nginx的配置需要先找到nginx的配置文件位置,该文件一般位于/etc/nginx/nginx.conf
文件中,当然也可以使用如下命令找到配置文件的位置:

1
nginx -t

该命令会检测配置文件是否正确,并输出配置文件的路径信息。
因此该命令可以在进行端口转发、ssl证书加密等配置之后检测配置是否正确。

  • Title: Nginx使用
  • Author: 呆呆的猪胖胖
  • Created at : 2025-08-20 00:00:00
  • Updated at : 2025-08-20 16:14:05
  • Link: https://blog.cflmy.cn/2025/08/19/Technology/Web/Nginx/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
Nginx使用