ubuntu装nginx--ubuntu22.04 配置 nginx 反向代理 - # 输出:nginx version: nginx/1

📅 2026-11-30 👤 拼多多助力营销技巧 📂 拼多多助力神器 👁️ 549 次阅读

一、安装nginx及常见命令

1.1 安装nginx

# 更新apt-get源

sudo apt-get update

# 安装

sudo apt-get install nginx

# 安装后将自动开启nginx服务,打开浏览器输入ip即可查看初始页面

# 查看安装版本

nginx -v

# 输出:nginx version: nginx/1.18.0 (Ubuntu)

# systemctl命令

# 查看状态

sudo systemctl status nginx

# 启动

sudo systemctl start nginx

# 停止

sudo systemctl stop nginx

# 重启

sudo systemctl restart nginx

# 开启自动启动

sudo systemctl enable nginx

1.2 nginx常见命令

# 检查 Nginx 配置文件地址

sudo nginx -t

sudo nginx -s reload # 重新载入配置文件

sudo nginx -s reopen # 重启 Nginx

sudo nginx -s stop # 停止 Nginx

# 当然使用上文中的 sudo systemctl 也是可以的

二、Nginx 配置

2.1 修改nginx主配置文件

cd /etc/nginx

sudo nano nginx.conf

可以修改配置内容如下:

user www-data;

worker_processes auto;

pid /run/nginx.pid;

include /etc/nginx/modules-enabled/*.conf;

events {

worker_connections 768;

# multi_accept on;

}

http {

##

# Basic Settings

##

sendfile on;

tcp_nopush on;

types_hash_max_size 2048;

keepalive_timeout 65;

# server_tokens off;

# server_names_hash_bucket_size 64;

# server_name_in_redirect off;

include /etc/nginx/mime.types;

default_type application/octet-stream;

##

# SSL Settings

##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE

ssl_prefer_server_ciphers on;

##

# Logging Settings

##

access_log /var/log/nginx/access.log;

error_log /var/log/nginx/error.log;

##

# Gzip Settings

##

gzip on;

# gzip_vary on;

# gzip_proxied any;

# gzip_comp_level 6;

# gzip_buffers 16 8k;

# gzip_http_version 1.1;

# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##

# Virtual Host Configs

##

include /etc/nginx/conf.d/*.conf;

include /etc/nginx/sites-enabled/*;

}

#mail {

# # See sample authentication script at:

# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript

#

# # auth_http localhost/auth.php;

# # pop3_capabilities "TOP" "USER";

# # imap_capabilities "IMAP4rev1" "UIDPLUS";

#

# server {

# listen localhost:110; 拼多多帮助力入口

# protocol pop3;

# proxy on;

# }

#

# server {

# listen localhost:143;

# protocol imap;

# proxy on;

# }

#}

2.2 新增nginx子配置文件

通常子配置文件夹位于/etc/nginx/conf.d,也可以通过nginx -t查看当前加载的配置文件路径

添加子配置文件 static.conf

路由/的html文件路径通常有两个,一个是/usr/share/nginx/html, 一个是/var/www/html,ubuntu装nginx

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧