nginx: [emerg] unknown log format "access" in错误解决方法

本文介绍了解决CentOS系统中Nginx配置导致的错误:unknown log format 'access'的方法。通过在nginx.conf配置文件中正确添加log_format定义,可以有效解决该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在centOS系统中配置域名的过程中,访问浏览器可能出现
如下错误:
nginx: [emerg] unknown log format “access”。

解决:
在nginx.conf配置文件中 include vhost/*.conf; 前面添加

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" ' 
             '"$http_user_agent" $http_x_forwarded_for';
Internal Server Error The server encountered an internal error and was unable to complete your request. Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report. More details can be found in the server log. error.log监控内容如下: 2025/06/09 15:42:11 [emerg] 8200#8200: unknown directive "..." in /etc/nginx/sites-enabled/nextcloud.conf:5 2025/06/09 15:43:43 [emerg] 8242#8242: unknown directive "..." in /etc/nginx/sites-enabled/nextcloud.conf:5 nginx -t 检查结果如下: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful nextcloud.conf配置文件内容如下: server { listen 192.168.60.200:80; # 改为你的域名或 IP # 静态资源缓存 location ~* \.(?:ico|css|js|svg|png|jpg)$ { expires 30d; add_header Cache-Control "public"; } # Nextcloud 根目录 root /var/www/nextcloud; index index.php index.html; # 基础安全规则 location ~ /\. { deny all; access_log off; log_not_found off; } # PHP 处理 location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Nextcloud 路由规则 location / { try_files $uri $uri/ /index.php$request_uri; } # 强制重定向到 /.well-known 路径 location = /.well-known/carddav { return 301 /remote.php/dav; } location = /.well-known/caldav { return 301 /remote.php/dav; } }
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值