Trying to set up a reverse proxy, apache errors and does not start

September 18, 2019 268 views
Nginx Apache Ubuntu 18.04

I’m trying to set up a reverse proxy on my droplet, following this tutorial step by step -

i’m on the “change listening ports step” and whenever i try to reload apache - i get error message that it is not even active.
When i try to start apache with - sudo systemctl start apache2.service
i’m told that “job for apache2.service failed because the control process exited with error code.
When i do
systemctl status apache2.service jounralctl -xe to find out what’s wrong i get "syntax error on line 150” - which i have not touched i guess at all? I guess it’s a relatively easy fix but i have not found any comment about it..

2 Answers


You can open the apache configuration file on line 150 and see what’s there. You can also run the following command:

httpd -t

It will check the apache configuration file and see if there are syntax errors. You can also paste the 150 line of the config so we can check this for you.

Looking forward to your reply.


  • 150th line is

    include ports.conf

    i guess i dont have port.conf file?

    • Thanks for getting back to me.

      The file might be missing indeed, however the issue can be related with something else, so it’s better to check the syntax using the command I’ve mentioned above.

      What output do you get when you run:

      httpd -t

      Looking forward to your reply.

      • I think you mean apache2 -t command? i dont think this ubuntu has httpd?
        anyway - here is the output of apache2 -t

        config variable [$apache_run_dir] is not defined
        syntax error on line 80 DefaultruntimeDr not defined, must be a valid directory, absolute or relative to serverroot 
        • That is correct, for Ubuntu it’s apache2 -t and for CentOs is httpd -t

          This is due to changes in the apache configuration file after the upgrade, and no new apache environment variables have been imported.

          Would you mind running the following command in order to sort this:

          source /etc/apache2/envvars


          . /etc/apache2/envvars

          And then start apache.

          Let me know how it goes.

          • sudo apache2 source /etc/apache2/envvars gives me the variety of command options while
            sudo apache2 source /etc/apache2/envvars-k start

            does nothing and starting apache with sudo systemctl start apache2.service still produces same error.
            Am i doing something wrong?

Did you run the source command like this:

source /etc/apache2/envvars


sudo apache2 source /etc/apache2/envvars

I’ve had a similar issue and using the “source /etc/apache2/envvars
” command sorted the issue for me.

Looking forward to your reply.

  • source /etc/apache2/envvars

    does nothing for me, just moves to next input

    sudo apache2 source /etc/apache2/envvars

    takes me to various command list, mostly vhost and serveroot related

    • Hello, @Dotnix

      Can you check if the following directory exists and if not to create it? The directory in question is /var/run/apache2

      To create it run:

      mkdir /var/run/apache2

      and then try to start apache.

      Let me know how it goes.


    • [deleted]
Have another answer? Share your knowledge.