本地是用PVE系统LXC容器部署Ubuntu
Nginx代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| server { listen 80; listen [::]:80; server_name 域名;
location / { root /usr/share/nginx/typecho; index index.php; }
location ~ .*\.php(\/.*)*$ { root /usr/share/nginx/typecho; fastcgi_split_path_info ^(.+?.php)(/.*)$; fastcgi_pass 127.0.0.1:6666; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
server { listen 443 ssl; listen [::]:443 ssl; server_name 域名;
ssl_certificate /root/.acme.sh/l证书路径/fullchain.cer; ssl_certificate_key /root/.acme.sh/l证书路径/lmgblog.dynv6.net.key;
ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256'; ssl_prefer_server_ciphers on;
root /usr/share/nginx/typecho; index index.php;
location ~ .*\.php(\/.*)*$ { root /usr/share/nginx/typecho; fastcgi_split_path_info ^(.+?.php)(/.*)$; fastcgi_pass 127.0.0.1:6666; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
|
修改Nginx主配置文件,在 http { 下方添加:
1 2 3
| gzip_comp_level 5; gzip_types text/plain text/css application/javascript; ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256';
|
修改 /etc/security/limits.conf 文件: 你可以将文件描述符限制增加到更高的值,以确保系统在重启后继续使用该设置。
备份文件
1 2
| cp /etc/security/limits.conf /etc/security/limits.conf.bak
|
修改文件
1 2
| vim /etc/security/limits.conf
|
添加以下内容
1 2 3
| * soft nofile 10000 * hard nofile 10000
|
修改 /etc/pam.d/common-session 文件: 为了确保用户登录时生效,你需要在 /etc/pam.d/common-session 中添加一行:
备份文件
1 2
| cp /etc/pam.d/common-session /etc/pam.d/common-session.bak
|
修改文件
1 2
| vim /etc/pam.d/common-session
|
添加以下内容
1 2
| session required pam_limits.so
|
修改 systemd 配置(针对 systemd 管理的服务): 如果你使用的是 systemd(大多数现代 Linux 发行版都使用 systemd),你还需要为 systemd 配置文件设置文件描述符限制。
备份文件
1 2
| cp /etc/systemd/system/multi-user.target.wants/nginx.service /etc/systemd/system/multi-user.target.wants/nginx.service.bak
|
修改文件
1
| vim /etc/systemd/system/multi-user.target.wants/nginx.service
|
在 [Service] 部分添加以下内容:
重新加载配置
1 2 3
| sudo systemctl daemon-reload sudo systemctl restart nginx
|
或重启系统