Master Web Hosting: Step-by-step Apache Installation & Configuration with Multi-Site Setup!



Master Web Hosting: Step-by-step Apache Installation & Configuration with Multi-Site Setup!

Master Web Hosting: Step-by-step Apache Installation & Configuration with Multi-Site Setup!

Welcome to our comprehensive tutorial on Apache server setup for hosting multiple websites! 🌐💻

If you’re looking to expand your web hosting capabilities or simply want to learn how to efficiently manage multiple websites on a single server, you’re in the right place. In this step-by-step guide, we’ll walk you through every aspect of installing, configuring, and optimizing your Apache server.

Here’s what you can expect from this tutorial:
🔹 **Introduction to Apache**: Get familiar with Apache, the industry-standard web server known for its reliability and performance.

🔹 **Installation**: Learn how to install Apache on your server, making sure you have all the necessary components in place.

🔹 **Configuration**: Dive deep into Apache’s configuration files and discover how to set up virtual hosts, manage server resources, and enhance security.

🔹 **Multiple Website Hosting**: We’ll guide you through the process of hosting multiple websites on a single Apache server, simplifying your web management tasks.

🔹 **Domain Setup**: Understand how to configure domain names to point to your Apache server, ensuring seamless access to your hosted websites.

By the end of this tutorial, you’ll have the knowledge and confidence to set up your Apache server and host multiple websites effortlessly. Whether you’re a web developer, a freelancer managing client sites, or a business owner looking to consolidate your online presence, this tutorial will empower you.

Don’t forget to like this video, subscribe to our channel for more valuable tutorials, and share this video with anyone interested in mastering web hosting with Apache! Let’s dive in and unlock the world of web hosting excellence together. 🚀🌐💡

**Steps to follow**

getenforce
vi /etc/selinux/config

SELINUX=disabled

systemctl status firewalld
systemctl disable –now firewalld
init 6
yum clean all
yum install httpd
ip a
getenforce
systemctl status httpd
systemctl enable –now httpd
systemctl status httpd
mkdir -p /var/www/sites/domain1/html
mkdir -p /var/www/sites/domain2/html
mkdir -p /var/www/sites/domain3/html
mkdir -p /var/log/httpd/domain1
mkdir -p /var/log/httpd/domain2
mkdir -p /var/log/httpd/domain3
vi /var/www/sites/domain1/html/index.html
vi /var/www/sites/domain2/html/index.html
vi /var/www/sites/domain3/html/index.html
cd /etc/httpd/
mkdir sites-{available,enabled}
cd sites-available/
touch domain{1..3}.conf
ls
vi domain1.conf

[VirtualHost *:80]
ServerName www.domain1.com
ServerAlias domain1.com
DocumentRoot /var/www/sites/domain1/html
ErrorLog /var/log/httpd/domain1/error.log
CustomLog /var/log/httpd/domain1/access.log combined
[/VirtualHost]

vi domain2.conf

[VirtualHost *:80]
ServerName www.domain2.com
ServerAlias domain2.com
DocumentRoot /var/www/sites/domain2/html
ErrorLog /var/log/httpd/domain2/error.log
CustomLog /var/log/httpd/domain2/access.log combined
[/VirtualHost]

vi domain3.conf

[VirtualHost *:80]
ServerName www.domain3.com
ServerAlias domain3.com
DocumentRoot /var/www/sites/domain3/html
ErrorLog /var/log/httpd/domain3/error.log
CustomLog /var/log/httpd/domain3/access.log combined
[/VirtualHost]

cd ..

vi /etc/httpd/conf/httpd.conf

Open file /etc/httpd/conf/httpd.conf and at the very end of the file add following text:
IncludeOptional sites-enabled/*.conf

Set webmaster email address:
ServerAdmin [email protected]

Set main document root:
DocumentRoot “/var/www/sites”

Configure main document root:
[Directory “/var/www/sites”]
AllowOverride All
Options FollowSymLinks
# Allow open access:
Require all granted
[/Directory]

ln -s /etc/httpd/sites-available/domain1.conf /etc/httpd/sites-enabled/domain1.conf
ln -s /etc/httpd/sites-available/domain2.conf /etc/httpd/sites-enabled/domain2.conf
ln -s /etc/httpd/sites-available/domain3.conf /etc/httpd/sites-enabled/domain3.conf

systemctl restart httpd

**N.B.**: Instead of using square bracket mentioned above for conf file, use the greater than & less than symbol

Open the Path in local system if it is windows C:WindowsSystem32driversetc , if it is linux then add this entry in /etc/hosts

x.x.x.x www.domain1.com domain1.com
x.x.x.x www.domain2.com domain2.com
x.x.x.x www.domain3.com domain3.com