- November 25, 2020
- saptrxuy_learnit
- 0 Comments
- 2540 Views
- 1 Likes
- Apache, XAMPP
Creating virtual host in Apache
1. Create hosts file entry for domain and IP in Xampp
2. Include external virtual host config file in httpd.conf
3. Create virtual host entry
4. Restart your Apache Web Server
5. Check your website in browser
6. Introduction to Apache Web Hosting
1.Create hosts file entry for domain and IP in Xampp ▲
1. Open host file
1a. In Linux
sudo gedit /etc/hosts
1b. In Windows (as Administrator):
notepad c:\windows\system32\drivers\etc\hosts
2. Add IP address and domain name in the above file. In this example, we are using domain name tm.xcelvations.loc
127.0.0.1 tm.xcelvations.loc
3. Save and close the file.
4. Go to command prompt,
ping tm.xcelvations.loc
You should see some response coming.
1.1.Code ▲
1:127.0.0.1 tm.xcelvations.loc
1.2.How to run ▲
1.3.Output ▲
ping tm.xcelvations.loc PING tm.xcelvations.loc (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.043 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.083 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.088 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.101 ms 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.085 ms 64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.086 ms
2.Include external virtual host config file in httpd.conf ▲
Go to apache httpd.conf file. If you are using xampp, it will be in xampp/conf folder.
Search for vhosts.conf entry
If it is commented, remove # to uncomment it.
Save
2.1.How to run ▲
3.Create virtual host entry ▲
Go to apache httpd-vhosts.conf file. If you are using xampp, it will be in xampp/etc/extra/httpd-vhosts.conf.
Open vhosts.conf file and type provided code
Here in document root you need to provide path of your project folder after /Applications/localsites/. For example: DocumentRoot “/Applications/localsites/tm.xcelvations.loc”
In our case tm.xcelvations.loc is our project file.
Now save your file.
3.1.How to run ▲
3.2.Output ▲
ServerAdmin webmaster@tm.xcelvations.loc DocumentRoot "/Applications/localsites/tm.xcelvations.loc" ServerName tm.xcelvations.loc ErrorLog "logs/tm-xcelvations-loc-error.log" CustomLog "logs/tm-xcelvations-loc-access.log" common <directory "="" applications="" localsites="" tm.xcelvations.loc"=""> AllowOverride All Require all granted Allow from All
4.Restart your Apache Web Server ▲
Step1 Go to your XAMPP.
Step 2 Go to Manage Server.
Step 3 Restart your Apache Web Server.
5.Check your website in browser ▲
Go to your browser and search for http://tm.xcelvations.loc
If you get a page like below image.
Congratulation you have create a Virtual Web Server.
6.Introduction to Apache Web Hosting ▲
See more at https://httpd.apache.org/
Leave a Comment