Plesk

Apache or nginx fails to start in Plesk: BIO_new_file: certificate not found: No such file or directory: nginx: configuration file /etc/nginx/nginx.conf test failed

Symptoms

Cause

Leftover configuration of the removed domain. The certificate file from the error can be found in different configuration files:

# grep -rl cert-rWXDy2 /var/www/vhosts/system/ | sort | uniq
/var/www/vhosts/system/example.com/conf/httpd.conf
/var/www/vhosts/system/example.com/conf/nginx.conf

Resolution

  1. Connect to the server via SSH.

  2. Locate the configuration files that mention the certificate:

    # grep -r cert-rWXDy2 /var/www/vhosts/system/*
    /var/www/vhosts/system/example.com/conf/httpd.conf: SSLCertificateFile /usr/local/psa/var/certificates/cert-rWXDy2
    /var/www/vhosts/system/example.com/conf/nginx.conf: ssl_certificate /usr/local/psa/var/certificates/cert-rWXDy2;

  3. Remove them:

    # rm -f /var/www/vhosts/system/example.com/conf/nginx.conf

    # rm -f /var/www/vhosts/system/example.com/conf/httpd.conf

  4. Remove the symlink for the config file:

    # rm -f /etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf
    # rm -f /etc/nginx/plesk.conf.d/vhosts/example.com.conf

  5. If the same error happens again, find and change the extension of the leftover config files:

    # find /etc/httpd/ /etc/nginx/ -name *example.com*.conf -print0 | xargs --null -I{} mv {} {}_leftover

    And verify the operation with:

    # find /etc/httpd/ /etc/nginx/ -name *example.com*
    /etc/httpd/conf/plesk.conf.d/webmails/example.com_webmail.conf_leftover
    /etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf_leftover
    /etc/nginx/plesk.conf.d/webmails/example.com_webmail.conf_leftover
    /etc/nginx/plesk.conf.d/vhosts/example.com.conf_leftover