42 F
Nashville
Thursday, November 21, 2024

How to Install the Apache Web Server on CentOS 9

Apache is available within CentOS's default software repositories, which means you can install it with yum.

How to Create Users in Linux

Linux is a multi-user system, meaning that more than one person can interact with the same system simultaneously.

How to Create Bash Aliases

This tutorial demonstrates how to use the alias command to create personalized shortcuts, which can help you save time and feel less frustrated.

How to Create Apache Virtual Hosts on CentOS 9

First, ensure that Apache is installed on your CentOS 9 system. 

Virtual Hosts are defined within configuration files with a .conf extension

Create a new file

vi /etc/httpd/conf.d/mydomain.com.conf

In this file, you’ll set up a block for your domain:

<VirtualHost *:80>

ServerName mydomain.com

ServerAlias www.mydomain.com

DocumentRoot /var/www/mydomain

ErrorLog /var/log/httpd/mydomain-error.log

</VirtualHost>

Check for syntax errors after configuring your virtual hosts

apachectl configtest

If you get a ‘Syntax OK’ output, restart apache to apply the changes:

systemctl restart httpd

Setup local hosts file

If you’re testing your configuration locally, edit your /etc/hosts file to point the domain to your local server

127.0.0.1 mydomain.com www.mydomain.com

Similar Articles

- A word from our sponsors -

Follow Us

Most Popular