Home > Software engineering >  How to get Apache to bind correctly to a Virtual Host
How to get Apache to bind correctly to a Virtual Host

Time:04-22

I have been working on setting up a website and I am using Apache on a Ubuntu 20.04 LS VM. I have the domain configured to point to the server and https is set up and working but whenever I go to the domain I get this view. Apache Server View

I have tried to get the domain to bind with the virtual host by using the server name tag but that is not working. This is my config file: Apache Config File I am new to the world of running servers so sorry if this question is stupid:). Let me know if I can add anything that would be helpful in this situation. This is the only website I am trying to host on this VM. Also, apache does not think that the folder shown in the image exists in the filesystem. I do not know if this would affect anything but to get my website files on the server I downloaded all the files into backpacking-project. Thanks.

CodePudding user response:

To correct the site issue, change DocumentRoot to

/var/www/backpacking-project/backpackingProject

Next, you should not allow Apache to display directory contents. Add these lines:

<Directory /var/www/backpacking-project/backpackingProject>
  Options -Indexes
</Directory>

Apache Directory Listings

Next you should define the default page. Assuming the default page is index.html, add this line to the previous Directory section:

DirectoryIndex index.html

Change index.html to whatever you are using, e.g. for PHP use index.php or home.php, etc.

CodePudding user response:

I figured out the reason why it was not working. It was because I uploaded a folder of my files to the server and apache did not recognize it in the filesystem. I uploaded the files separately that that worked.

  • Related