How to configure Apache Virtual Host in OpenSUSE
To configure Apache Virtual Host in OpenSUSE 13.2
Virtual Hosting is a method to host more than one domain on a web server. Virtual Hosting is of two types - Name based and IP based. While multiple sites can be run on the same IP address with Name based Virtual Hosting, the IP based virtual hosting can have different IP addresses for each site. This article simplifies the configuration procedure of Apache Virtual Host in OpenSUSE 13.2
First step is to install Apache by deploying the Zypper command. Once the installation of Apache is complete, start the Apache service with the help of following command. Once it is done, enable the apache service with the following command. You can verfity the status of apache service with the below mentioned command.
Once you have installed and checked the status of Apache, go to its Web-root directory and create a new directory as mentioned below. Create a new file in the above mentioned directory by using the following command. Enter some text in the newly created file. Create a new virtualhost configuration file in the below mentioned directory and configure it as follows. Once you are done with the configuration, open the host file and enter Virtualhost domain name with your server-ip. Give effect to the virtual host you have just created by restarting the Apache server with the help of the following command. Enter the newly created domain on your web browser to check the Virtual Host. The browser will display the site you have created. To create multiple domains using Virtual Host, create another new directory in Apache' s document root directory and repeat the previous steps. Now open the browser and call the newly created domain name to verify its functioning.
To Install Apache
linuxhelp:/home/user1 # zypper install apache2
Retrieving repository ' openSUSE-13.2-Non-Oss' metadata ...................[done]
Building repository ' openSUSE-13.2-Non-Oss' cache ........................[done]
Retrieving repository ' openSUSE-13.2-Oss' metadata .......................[done]
Building repository ' openSUSE-13.2-Oss' cache ............................[done]
Retrieving repository ' openSUSE-13.2-Update' metadata ....................[done]
.
.
.
(6/6) Installing: apache2-prefork-2.4.10-31.1 ............................[done]
linuxhelp:/home/user1 # systemctl start apache2
linuxhelp:/home/user1 # systemctl enable apache2
linuxhelp:/home/user1 # systemctl status apache2
To Configure Apache Virtual Host
linuxhelp:/home/user1 # cd /srv/www/htdocs/
linuxhelp:/srv/www/htdocs # mkdir site1
linuxhelp:/srv/www/htdocs # vim index.html
linuxhelp:/home/user1 # vim /etc/apache2/conf.d/vhost.conf
DocumentRoot " /srv/www/htdocs/site1"
ServerName www.linuxhelp1.com
linuxhelp:/home/user1 # vim /etc/hosts
192.168.5.170 www.linuxhelp1.com
To restart the Apache server
linuxhelp:~ # systemctl restart apache2.service
To check Apache Virtual Host