How to host a website in IP address

In our concern, we are running a classified website and planning to host same website to different server for development and testing purpose so that it wont affect the production server if we want to implement anything newly. Follow the below steps to do it.

We are using most of the servers with cpanel and few server not having cpanel. I have used below commands to checked the databases size. If you want to check below commands you should have root access to do it. Just login to mysql service and use the commands. You don’t want to change anything on this command. Just copy and past to get output.

1) Sample httpd.conf file

See the sample httpd.conf file for your understandings. our site is serving from Method-1

[email protected] [~]# nano /usr/local/apache/conf/httpd.conf
GNU nano 2.0.9                                   File: /usr/local/apache/conf/httpd.conf

# Ensure that Apache listens on port 80
Listen 80

# Method -1
# Running several name-based web sites on a single IP address
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80 

# Method -2
#Name-based hosts on more than one IP address
#NameVirtualHost  82.165.133.65:80

<VirtualHost *:80>
    ServerName 2daygeek.com
    ServerAlias www.2daygeek.com
    DocumentRoot /home/2daygeek/public_html
	ErrorLog /home/2daygeek/public_html/error_log
    ServerAdmin [email protected]
    
	<Directory "/u01/zend/apache2/htdocs/www.mrjalebi.com/">
    AllowOverride all
    Allow from all
    </Directory>
	
</VirtualHost>

2) How to host a website in IP address

use the below format to host your website in IP address instead of domain name. Make sure you have to create the document root and added the required IP address.

[email protected] [~]# nano /usr/local/apache/conf/httpd.conf
GNU nano 2.0.9                                   File: /usr/local/apache/conf/httpd.conf

# Ensure that Apache listens on port 80
Listen 80

# Method -2
#Name-based hosts on more than one IP address
NameVirtualHost  82.165.133.65:80

<VirtualHost 82.165.133.65:80>
    ServerName 82.165.133.65
    DocumentRoot "/home/2daygeek/public_html"
	ErrorLog /home/2daygeek/public_html/error_log
    ServerAdmin [email protected]
    
	<Directory "/home/2daygeek/public_html">
    AllowOverride all
    Allow from all
    </Directory>
	
</VirtualHost>

We are preparing all articles in-depth to understand by all level/stage Linux administrators. If the article is useful for you, then please spend less than a minute to share your valuable comments in our commenting section.

Please stay tune with us…Good Luck 🙂

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...