Celeb Glow
news | March 24, 2026

Need help configuring apache on Ubuntu 20.04

I successfully installed the Apache webserver on my Ubuntu 20.04 laptop.

Now I need to know how to change the configuration file(s) so that I can place my CGI scripts (which will be in Perl).

From my time using Apache2.4 under Windows 10, it was easy. I just made needed changes to the httpd.conf file. Under this configuration, things are very different so I am not sure how to make the needed changes. I looked at the apache2.conf file and the declaration for the ServerRoot directive was commented out.

While I was reading up on how to install apache I saw a statement which read "Documentation for the web server itself can be found by accessing the "manual" if the apache2-doc package was installed on this server". I ran an apt command and installed the apache2-doc package, but how do I use it?

I need to know how to change the configuration files so that I can define the location of the directory containing all my Perl CGI scripts.

1 Answer

In Ubuntu (and in other distros), Apache configuration is organized in multiple files for easier maintenance and upgrading. You would find:

  • /etc/apache2/apache2.conf: Main config file for global configuration, usually discourage to modify this file.
  • /etc/apache2/conf-available/: Directory where you can add different configurations files to keep things well organized.
  • /etc/apache2/conf-enabled/: Directory that contains symlinks from /etc/apache2/conf-available directory. Every file or symlink in this directory is automatically included by apache2.conf.
  • /etc/apache2/sites-available/: Directory to keep your sites configuration files. If you have multiple websites hosted on your Apache, you can have multiple files here, one for each one. Otherwise, you can just use the 000-default.conf file that already exists there.
  • /etc/apache2/sites-enabled/: Directory that contains symlinks from /etc/apache2/sites-available directory. Every file or symlink in this directory is automatically included by apache2.conf.
  • /etc/apache2/mods-available/: Directory where all the available Apache modules are stored and their configuration files.
  • /etc/apache2/mods-enabled/: Directory that contains symlinks from /etc/apache2/mods-available directory. Every file or symlink in this directory is automatically included by apache2.conf.

There are few commands that makes creating and deleting these symlinks from *-available to *-enabled a bit easier, like:

  • a2ensite: Enables a site by creating the symlink to sites-enabled.
  • a2dissite: Disables a site by deleting the symlink from sites-enabled.
  • a2enmod: Enables a module by creating the symlink to mods-enabled.
  • a2dismod: Disables a module by deleting the symlink from mods-enabled.
  • a2enconf: Enables a config by creating the symlink to conf-enabled.
  • a2disconf: Disables a config by deleting the symlink from conf-enabled.

Most likely, you would just need to modify the file /etc/apache2/sites-enabled/000-default.conf with your site config if your requirements are simple. For more complex scenarios, is recommended to have your own site config.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy