Wednesday, December 4, 2024

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

Share

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/html/example with the path to your website’s files:

<VirtualHost *:80>
	ServerName example.com
	DocumentRoot /var/www/html/example
	<Directory /var/www/html/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

Read more

Local News

Kaninchen alleine halten – ist das eine gute idee ?. Block. Experience the flawless beauty of seamless surfaces with asr california today.