每次重启服务器报错 Nginx配置规则错误:
Nginx配置规则错误:nginx version: nginx/1.22nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is oknginx: [emerg] mkdir() /dev/shm/nginx-cache/jiepaike.com failed (2: No such file or directory)nginx: configuration file /www/server/nginx/conf/nginx.conf test failed如果你希望继续使用/dev/shm以获得更快的缓存读写性能可以创建一个 systemd 服务在 Nginx 启动前自动创建目录。[Unit] DescriptionCreate nginx cache directories in /dev/shm Beforenginx.service [Service] Typeoneshot ExecStart/bin/mkdir -p /dev/shm/nginx-cache/jiepaike.com /dev/shm/nginx-cache/jiepaiquan.com ExecStartPost/bin/chown -R www:www /dev/shm/nginx-cache [Install] WantedBymulti-user.target然后启用并启动systemctl enable nginx-cache-setup.service systemctl start nginx-cache-setup.service之后每次系统启动时都会自动创建目录Nginx 即可正常启动。