Wednesday, July 3, 2024

How to Setup Apache with a Virtual Host in CentOS 9 Stream

To setup Apache with a virtual host in CentOS 9 Stream, you can follow these steps:

Guide To Configuring Apache With A Virtual Host

Install Apache

sudo dnf install httpd

Start the Apache service

sudo systemctl start httpd

Enable Apache to start on boot

sudo systemctl enable httpd

Configure the virtual host

Create a new configuration file for your virtual host. For example, create a file named mydomain.conf in the /etc/httpd/conf.d/ directory:

sudo nano /etc/httpd/conf.d/mydomain.conf

Add the following content to the file. Replace example.com with your domain name and /var/www/wptbox/example with the path to your website’s files:

<VirtualHost *:80>
	ServerName example.com
	DocumentRoot /var/www/wptbox/example
	<Directory /var/www/wptbox/example>
		Options FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>
</VirtualHost>

Save the file and exit the text editor.

Adjust firewall settings if necessary

If you have firewalld enabled, allow HTTP traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Finally, update your DNS settings to point your domain to the server’s IP address.

Your virtual host should now be set up and accessible through the specified domain name. Make sure you have the necessary files in the specified document root directory to serve your website content.

Related Articles

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

At nurudeen technology solutions, we offer a wide range of services, including :. A speed bag workout involves hitting a small, rapidly moving bag to improve hand eye coordination, rhythm, and timing.