1、下载
wget http://nginx.org/download/nginx-1.23.1.tar.gz
2、 安装相关依赖包
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g zlib1g-dev
sudo sudo apt-get install openssl
sudo sudo apt-get install libssl-dev
3、 解压安装
tar -zxvf nginx-1.18.0.tar.gz -C /opt/nginx-1.23.1
cd /opt/nginx-1.23.1
# 设置安装目录为/usr/local/nginx
./configure --prefix=/usr/local/nginx
./configure --prefix=/usr/local/nginx --with-stream --with-http_ssl_module #后面用到stream需要这样配置
make
make install
后续修改参考之前写过centos安装步骤
centos7安装nginx1.18.0详细步骤_centos7系统部署nginx-1.18.0教程-CSDN博客
4、ubuntu22.04直接安装nginx
sudo apt update
sudo apt install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
Nginx的配置文件位于 /etc/nginx/nginx.conf
直接把写好的配置文件放在 /etc/nginx/conf.d
sudo nginx -t # 检查配置文件的语法是否正确