php-fpm doesn't create .sock file

php-fpm doesn't create .sock file

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

php-fpm doesn't create .sock file

When deploying a stack that replaces Apache with nginx, the most common friction point is locating the Unix socket that bridges the two services. If service start php-fpm runs without error but no .sock file appears in /var/run, it usually indicates a mismatch between how the service was started and where nginx expects to connect.

The absence of the socket isn't necessarily a failure; it's often a configuration artifact. On Amazon Linux, specifically when using RPM packages like php70w-fpm, the default behavior is to create the socket in /var/run/php-fpm.sock. However, this path assumes that nginx is configured to look there and that the service started with default permissions.

The core issue often lies in two specific areas: the actual location of the socket file versus the path defined in your nginx configuration, and the ownership or permissions preventing the web server from accessing it. When you run find / -name "*.sock", seeing only /var/run/rpcbind.sock confirms that the PHP process either failed to initialize its listener or is writing to a non-standard location not yet discovered by your search scope due to permission boundaries.

To resolve this, you must first verify where the socket actually exists. The most reliable method is to check the specific directory configured in the php-fpm service definition. You can inspect the current configuration by looking at the systemd unit file or the ini files loaded by PHP-FPM:

systemctl show php-fpm | grep SocketFile
# Or, if using a traditional init script context:
grep "listen" /etc/php.ini

If the socket is indeed missing from /var/run, check the logs in /var/log/php-fpm/ or journalctl -u php-fpm -n 50. You might find messages indicating that the process bound to a different directory, often /run/php-fpm.sock on newer distributions. The path differs slightly between Amazon Linux versions and the specific PHP version package (e.g., php70w).

Once you locate the correct path, update your nginx configuration file (typically in /etc/nginx/conf.d/ or /etc/nginx/sites-available/) to point to that exact location. A typical server block configuration looks like this:

server {
    listen 80;
    root /var/www/html;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php-fpm.sock; # Adjust path based on your actual socket location
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

Crucially, after updating the configuration, you must reload nginx and restart php-fpm for changes to take effect. Simply restarting nginx won't fix a missing socket if the underlying process isn't running or bound correctly.

systemctl restart php-fpm
nginx -t && systemctl reload nginx

If the socket still fails to appear, check the permissions. The PHP-FPM process usually runs as a specific user (often www-data or php-fpm). If that user lacks write permissions in the target directory, the socket won't be created. Ensure the directory is owned by the correct group:

chown -R php-fpm:php-fpm /run/php-fpm.sock  # Or wherever the socket ends up
chmod 660 /run/php-fpm.sock

Another common pitfall involves SELinux on Amazon Linux. If SELinux is enforcing, it might block the PHP-FPM daemon from creating a socket in /var/run even if file permissions allow it. You can check for denials with ausearch -m avc -ts recent. If present, you may need to adjust the context or create a custom policy, though disabling SELinux is often a pragmatic solution for development instances.

Finally, consider the architecture of your application stack. While the socket approach is standard for performance and isolation, some modern setups prefer TCP sockets (127.0.0.1:9000) or even HTTP-based internal routing to simplify firewall rules and debugging. However, sticking to the Unix socket is generally preferred for low-latency communication between nginx and PHP-FPM.

If you are building a production stack on Laravel, ensuring this connection is robust is vital for stability. For advanced guidance on securing these configurations and integrating with modern PHP versions, refer to resources like https://laravelcompany.com, which often covers deployment best practices for high-availability setups.

Our network