How to configure Lamp stack vhost config file in Apache?

Hi,

I am using ubuntu 20.04 on powershell. I have a question about my Lamp web server for my wordpress website. I know this question will be very basic but I need to learn logic of vhost config file.

When i cd /etc/apache2/sites-available , i am getting this output: 000-default.conf default-ssl.conf homelistt.com.conf homelistt.com.conf.save homelistt.com-le-ssl.conf .

And when i cd /etc/apache2/sites-enabled/ , output is : homelistt.com.conf homelistt.com-le-ssl.conf

As far as i know my main vhost configuration file is "homelistt.com.conf" under "/etc/apache2/sites-enabled/". Or should i create another one?

If we assume that "homelistt.com.conf" file under "/etc/apache2/sites-enabled/" is my vhost configuration file;

-when i make a change in it, do i have to implement that change in "homelistt.com-le-ssl.conf" too? Because last time when i change my server name as: www.homelistt.com in "homelistt.com.conf" file it was homelistt.com in homelistt.com-le-ssl.conf file.

Thank u.

My domain is:www.homelistt.com

I ran this command: cd /etc/apache2/sites-enabled/

It produced this output: homelistt.com.conf homelistt.com-le-ssl.conf

My web server is (include version): Apache/2.4.41 (Ubuntu)

The operating system my web server runs on is (include version): linux

My hosting provider, if applicable, is:

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel):

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):

2 Likes

Welcome back @elvn

You were polite in your prior thread so I will try to give some general advice to this.

There are many ways to manage your server config. But, the common way on Ubuntu is to use sites-available and sites-enabled like you have started. I assume you already know about the a2ensite and a2dissite commands

Your main Apache conf will have an include statement for sites-enabled so those are the only VHost defs that matter. You edit them in sites-available as the sites-enabled is just a symlink to those files.

You have a VHost conf file for HTTP (listen port 80) and that is usually very small. Now that you have HTTPS working it would just redirect requests to HTTPS (listen port 443). Any extra config just goes into the HTTPS VHost as it will be doing all the work. You could add redirect logic in your port 80 VHost so it does not redirect the acme challenge URL but that is optional.

There are many sources to learn about Apache config. Sadly, many google results are poor ... some are for very old Apache versions or for particular hosting service setups which do not apply to you. When starting it is easy to be led astray.

Some sources that may be better than others for you are:
Ask Ubuntu Forum
Apache Wiki
Apache Docs

Best of luck to you

4 Likes