Tag: PHP

  • Fixing Loopback Request Issue in WordPress in Docker

    If Site Health shows “Your site could not complete a loopback request” (or The REST API encountered an error) when running WordPress in Docker behind a reverse proxy (e.g., Caddy), the culprit is often that extra_hosts entry pointing to a container IP that changes on restart. Which is always as a solution to solve the loopback issue.

    The fix (use a Docker network alias)

    Let Docker’s built-in DNS keep things in sync by giving your proxy container a network alias that matches your site’s domain. Then all other containers resolve the alias to the current IP automatically. Would be a better solution than specifying the internal IP for PHP container:

    services:
      caddy:
        # ...your existing caddy config...
        networks:
          default:
            aliases:
              - example.com

    Now remove any extra_hosts lines you previously added to other services (like php).

    Apply & verify

    # Recreate containers
    docker compose up -d
    
    # From the php container, confirm the alias resolves
    docker compose exec php getent hosts example.com
    
    # (Optional) Hit wp-cron directly
    docker compose exec php curl -I https://example.com/wp-cron.php?doing_wp_cron=1

    Return to Tools → Site Health and re-check: loopback should pass, and scheduled tasks will run normally.

  • Docker Mounted Volumes Permission Issues with Nginx and PHP-FPM

    Prerequisites:

    • Official Nginx alpine Docker image
    • Official PHP Docker (Debian) image with fpm tags

    Get currenty PHP-FPM running user info:

    $ docker exec php_container_name id www-data
    uid=33(www-data) gid=33(www-data) groups=33(www-data)

    Change the owner of your existing mounted volume:

    chown 33:33 -R /srv/www
  • The Simplest MediaWiki Update Script for Single-Server MediaWiki Site

    System requirements:

    • User uploads $wgUploadDirectory are stored offsite
    • Non-Docker MediaWiki with normal setup
    • Composor installed (Can be installed automatically during updating)

    Goals:

    • Update MediaWiki with nearly zero downtime
    • Download and install latest tagged MediaWiki from tarball package
    • Update extensions and skins from latest git tagged branch
    • Install extension-specific dependencies during updating
    (more…)
  • Increase PHP-FPM File Upload Limit

    Nginx:

    • client_max_body_size

    PHP:

    • post_max_size
    • upload_max_filesize
  • WordPress 在 localhost MAMP 执行时出现 500 错误的解决方案

    /Applications/MAMP/logs/php_error.log 下看错误,如果是:

    PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate x bytes) in /path/to/file on line n

    那么就去 /Applications/MAMP/bin/php/php5.3.6/conf/php.ini 里把 memory_limit 改为 64M 或更大即可

  • Debian 手動編譯安裝 nginx + PHP-FPM 指北

    目前網上各種不靠譜的自動化安裝腳本不計其數。 nginx + PHP-FPM 教程也不多,本篇備忘錄重點針對 PHP-FPM 安裝,參考 nginx 官方 docs 與 Slicehost wiki 編寫而成

    (more…)