Skip to content

Fix duplicate gzip directive in WordPress installation script#166

Merged
andchir merged 3 commits intoandchir:mainfrom
konard:issue-165-b52ee0b335b3
Dec 31, 2025
Merged

Fix duplicate gzip directive in WordPress installation script#166
andchir merged 3 commits intoandchir:mainfrom
konard:issue-165-b52ee0b335b3

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented Dec 31, 2025

Summary

Fixes #165 - Resolves duplicate gzip directive error in WordPress installation script

Problem

The WordPress installation script was failing during Nginx configuration with the following error:

[X] Nginx configuration test failed
2025/12/31 12:56:42 [emerg] 29717#29717: "gzip" directive is duplicate in /etc/nginx/conf.d/gzip.conf:5
nginx: configuration file /etc/nginx/nginx.conf test failed

Root cause: The script was creating /etc/nginx/conf.d/gzip.conf with a gzip on; directive, but the default /etc/nginx/nginx.conf already contains gzip on; (line 46), causing a duplicate directive error.

Solution

Removed the duplicate gzip on; directive from the generated /etc/nginx/conf.d/gzip.conf file:

  • Before: The gzip.conf file included gzip on; which conflicted with the default nginx.conf
  • After: The gzip.conf file only contains additional gzip settings (compression level, types, etc.) without the duplicate directive
  • Added explanatory comment noting that gzip is already enabled in the main configuration

Changes

  • Modified scripts/wordpress.sh:747-804 - configure_gzip_compression() function
  • Removed gzip on; directive from the generated gzip.conf file
  • Added comment explaining that gzip is already enabled in nginx.conf
  • Preserved all other gzip configuration settings (compression level, MIME types, etc.)

Testing

Created and ran test script (experiments/test_gzip_config.sh) to verify:

  • ✅ Only one gzip on; directive exists (no duplicates)
  • ✅ All gzip configuration settings are properly applied
  • ✅ Nginx configuration test would pass

Impact

This fix ensures that:

  1. WordPress installation script completes successfully
  2. Nginx configuration test passes without errors
  3. Gzip compression is properly configured for optimal performance
  4. No duplicate directives exist in Nginx configuration

🤖 Generated with Claude Code

konard and others added 2 commits December 31, 2025 13:59
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: andchir#165
This commit fixes issue andchir#165 where the WordPress installation script
was failing with a duplicate gzip directive error during Nginx
configuration.

Problem:
- The script was creating /etc/nginx/conf.d/gzip.conf with "gzip on;"
- However, /etc/nginx/nginx.conf already has "gzip on;" by default
- This caused nginx -t to fail with: "gzip" directive is duplicate

Solution:
- Removed the duplicate "gzip on;" directive from gzip.conf
- Added explanatory comment noting that gzip is already enabled
- Kept all other gzip configuration settings (compression level, types, etc.)

The fix ensures that:
1. Nginx configuration test passes successfully
2. Gzip compression remains properly configured
3. No duplicate directives exist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Исправить скрипт установки wordpress Fix duplicate gzip directive in WordPress installation script Dec 31, 2025
@konard konard marked this pull request as ready for review December 31, 2025 13:02
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Dec 31, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.014759 USD
  • Calculated by Anthropic: $0.710310 USD
  • Difference: $-0.304449 (-30.00%)
    📎 Log file uploaded as GitHub Gist (317KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@andchir andchir merged commit e02508b into andchir:main Dec 31, 2025
konard added a commit to konard/andchir-install_scripts that referenced this pull request Dec 31, 2025
## Problem

When users ran the WordPress installation script multiple times:
1. First run with old script (before PR andchir#166) created gzip.conf with 'gzip on;' directive
2. PR andchir#166 was merged to fix the script, but doesn't recreate existing gzip.conf files
3. Second run with new script still fails because old gzip.conf has duplicate directive

Error on re-run:
```
[X] Nginx configuration test failed
2025/12/31 13:25:29 [emerg] 38935#38935: "gzip" directive is duplicate in /etc/nginx/conf.d/gzip.conf:5
```

## Root Cause

The script checks if gzip.conf exists and skips creation if it does (line 746).
This means old buggy gzip.conf files from before PR andchir#166 are never updated.

## Solution

Added detection and removal of outdated gzip.conf files:
- Before creating gzip.conf, check if existing file contains 'gzip on;' directive
- If found, remove the old file and recreate with correct configuration
- This ensures both new installations and updates get the correct config

## Changes

- Modified scripts/wordpress.sh:742-756 in configure_gzip_compression() function
- Added detection for outdated gzip.conf containing 'gzip on;' directive
- Added automatic removal and recreation of outdated config
- Created experiments/test_gzip_fix.sh to verify the fix works correctly

## Testing

Test script verifies:
✅ Old gzip.conf with 'gzip on;' is detected and removed
✅ New gzip.conf without 'gzip on;' is preserved
✅ All expected gzip directives are present

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Исправить скрипт установки wordpress

2 participants