Files
michaelschiemer/deployment/ansible/playbooks/check-phpfpm-config.yml

81 lines
3.1 KiB
YAML

---
- name: Check PHP-FPM Configuration in Detail
hosts: production
gather_facts: yes
become: no
tasks:
- name: Check PHP-FPM pool configuration
shell: |
cd ~/deployment/stacks/staging
echo "=== PHP-FPM www.conf listen configuration ==="
docker compose exec -T staging-app cat /usr/local/etc/php-fpm.d/www.conf 2>&1 | grep -E "(listen|listen.allowed_clients|listen.owner|listen.group|listen.mode|pm)" | head -20
echo ""
echo "=== Check PHP-FPM processes ==="
docker compose exec -T staging-app ps aux | grep php-fpm || echo "No php-fpm processes found"
echo ""
echo "=== Check PHP-FPM status page ==="
docker compose exec -T staging-app sh -c "SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 2>&1 || echo 'Status check failed'"
args:
executable: /bin/bash
register: phpfpm_config
ignore_errors: yes
failed_when: false
- name: Display PHP-FPM configuration
debug:
msg: "{{ phpfpm_config.stdout_lines }}"
- name: Check what interface PHP-FPM is listening on
shell: |
cd ~/deployment/stacks/staging
echo "=== Check listening interface ==="
docker compose exec -T staging-app netstat -tlnp 2>/dev/null | grep 9000 || \
docker compose exec -T staging-app ss -tlnp 2>/dev/null | grep 9000 || \
echo "Could not check listening interface"
echo ""
echo "=== Try to connect from nginx using FastCGI protocol ==="
docker compose exec -T staging-nginx sh -c "echo -e 'REQUEST_METHOD=GET\nSCRIPT_FILENAME=/var/www/html/public/index.php\n' | cgi-fcgi -bind -connect staging-app:9000 2>&1 | head -20" || echo "FastCGI test failed"
args:
executable: /bin/bash
register: listen_check
ignore_errors: yes
failed_when: false
- name: Display listening interface check
debug:
msg: "{{ listen_check.stdout_lines }}"
- name: Check PHP-FPM error logs
shell: |
cd ~/deployment/stacks/staging
echo "=== PHP-FPM error log ==="
docker compose exec -T staging-app tail -50 /var/log/php-fpm.log 2>&1 || \
docker compose exec -T staging-app tail -50 /usr/local/var/log/php-fpm.log 2>&1 || \
docker compose logs --tail=100 staging-app 2>&1 | grep -iE "(fpm|error|warning)" | tail -20 || \
echo "No PHP-FPM error logs found"
args:
executable: /bin/bash
register: phpfpm_errors
ignore_errors: yes
failed_when: false
- name: Display PHP-FPM errors
debug:
msg: "{{ phpfpm_errors.stdout_lines }}"
- name: Test actual request from outside
shell: |
cd ~/deployment/stacks/staging
echo "=== Test request from nginx to PHP-FPM ==="
docker compose exec -T staging-nginx sh -c "curl -v http://127.0.0.1/ 2>&1 | head -30" || echo "Request test failed"
args:
executable: /bin/bash
register: request_test
ignore_errors: yes
failed_when: false
- name: Display request test
debug:
msg: "{{ request_test.stdout_lines }}"