Websites show 502 Bad Gateway and Apache cannot be started: DocumentRoot must be a directory

Created:

2016-11-16 13:21:59 UTC

Modified:

2017-08-16 17:24:34 UTC

3

Was this article helpful?


Have more questions?

Submit a request

Websites show 502 Bad Gateway and Apache cannot be started: DocumentRoot must be a directory

Applicable to:

  • Plesk 11.x for Linux
  • Plesk 12.0 for Linux

Symptoms

  1. Websites are showing 502 Bad Gateway

  2. Apache is stopped and fails to start with the following message:

    # service httpd start
    Starting httpd: Syntax error on line 16 of /etc/httpd/conf/plesk.conf.d/server.conf:
    DocumentRoot must be a directory
    [FAILED]

    or with the following one:

    # service httpd start
    Starting httpd: Syntax error on line 16 of /etc/httpd/conf/plesk.conf.d/server.conf:
    DocumentRoot '/var/www/vhosts/default/htdocs' is not a directory, or is not readable
    [FAILED]

Cause

Default document root is missing or has incorrect ownership.

Resolution

  1. Find path to document root in /etc/httpd/conf/plesk.conf.d/server.conf file.
    By default it is set as /var/www/vhosts/default/htdocs :

    # grep 'DocumentRoot' /etc/httpd/conf/plesk.conf.d/server.conf
    DocumentRoot "/var/www/vhosts/default/htdocs"
  2. Check if the directory exists on a server:

    # ls -ld /var/www/vhosts/default/htdocs
    ls: cannot access /var/www/vhosts/default/htdocs: No such file or directory
  3. Create directory if it is missing:

    # mkdir /var/www/vhosts/default/htdocs
  4. Set correct ownership:

    # chown root:root /var/www/vhosts/default/htdocs
  5. Start Apache:

    # service httpd start
Have more questions? Submit a request
Please sign in to leave a comment.