Question

what command can I (i'm not a root) use to create Virtual host entry that should...

what command can I (i'm not a root) use to create Virtual host entry that should point my IP and port 8100

centos7

step by steps please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Set Up Multiple IP Addresses On A Single Network Interface

To set up IP-based virtual hosting, you need to have more than one IP address assigned to your server. Setting up multiple IP addresses on a single network interface is called "IP aliasing." It is very useful, particularly if your server only has one network interface card (NIC).

To set up multiple IPs, you need to edit the ifcfg-eth0 file:

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

Add/edit the following lines:

DEVICE="eth0"
ONBOOT=yes
BOOTPROTO=static
IPADDR0=192.168.1.42
IPADDR1=192.168.1.43
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8

Save and close the file when you are finished. Then restart the network service to make these changes take effect.

sudo service network restart

Set Up Multiple Instances Of Apache

By default Apache listens for incoming connections on port 80. For port-based virtual hosting, you need to tell Apache to listen for IP address 192.168.1.42 on port 80 and for IP address 192.168.1.43 on port 8080.

To set up multiple ports, you need to edit the httpd.conf file:

sudo nano /etc/httpd/conf/httpd.conf

Add/edit the following lines:

Listen 192.168.1.42:80
Listen 192.168.1.43:8080

Save and close the file, then restart Apache to make these changes take effect.

sudo systemctl restart httpd

Create The Directory Structure

First, you need to make a directory structure which will hold the web pages. This directory is known as "document root" for the domain.

In CentOS 7 the default Apache document root directory is /var/www/html/.

Now, create two directory for websites www.ip-vhost.com and www.port-vhost.com in the default Apache document root directory:

sudo mkdir -p /var/www/html/www.ip-vhost.com
sudo mkdir -p /var/www/html/www.port-vhost.com

Create Test Web Pages For Each Virtual Host

Now, you need to create an index.html file for each website which will identify that specific domain.

Let's create an index.html file for the www.ip-vhost.com ip virtual host.

sudo nano /var/www/html/www.ip-vhost.com/index.html

Add the following content.

<html>

<head>
  <title>www.ip-vhost.com</title>
</head>

<body>
  <h1>The ip-vhost.com virtual host is working!</h1>
</body>

</html>

Save and close the file when you are finished.

Similarly, create an index.html file for the www.port-vhost.com virtual host.

sudo nano /var/www/html/www.port-vhost.com/index.html

Add the following content.

<html>

<head>
  <title>www.port-vhost.com</title>
</head>

<body>
  <h1>The port-vhost.com virtual host is working!</h1>
</body>
</html>

Save and close this file as well. Now, you have the pages to test the virtual host configuration.

Set Up Ownership And Permissions

In CentOS 7 by default the Apache service runs as the user apache. You must change the ownership of these two virtual directories to apache, so that Apache can read and write data.

You can change the ownership with chown command.

sudo chown -R apache:apache /var/www/html/www.ip-vhost.com
sudo chown -R apache:apache /var/www/html/www.port-vhost.com

You should also make the Apache document root /var/www/html directory world readable, so that everyone can read files from that directory.

sudo chmod -R 755 /var/www/html

Now your web server has the permissions it needs to serve content.

Create Virtual Host Files

The next step is to create a virtual host configuration file for each website. The name of each configuration file must end with .conf.

Let's create a virtual host file for website www.ip-vhost.com.

sudo nano /etc/httpd/conf.d/ip-vhost.com.conf

Add the following content.

<VirtualHost 192.168.1.42:80>

  ServerName www.ip-vhost.com
  ServerAlias ip-vhost.com
  DocumentRoot /var/www/html/www.ip-vhost.com
  ErrorLog /var/www/html/www.ip-vhost.com/error.log
  CustomLog /var/www/html/www.ip-vhost.com/access.log combined

</VirtualHost>

Save and close the file when you are finished.

Similarly, create a virtual host file for website www.port-vhost.com.

sudo nano /etc/httpd/conf.d/port-vhost.com.conf

Add the following content.

<VirtualHost 192.168.1.42:8080>

  ServerName www.port-vhost.com
  ServerAlias port-vhost.com
  DocumentRoot /var/www/html/www.port-vhost.com
  ErrorLog /var/www/html/www.port-vhost.com/error.log
  CustomLog /var/www/html/www.port-vhost.com/access.log combined

</VirtualHost>

When you are finished, it is a good idea to check the syntax of the configuration. You can check the syntax of files with the following command:

sudo apachectl configtest

After the syntax check is done, restart Apache to make these changes take effect.

sudo systemctl restart httpd

Allow Apache Through The Firewall

Now, you need to allow the Apache port 80 and 8080 using FirewallD.

You can do this by running following commands:

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=8080/tcp

Now, reload the firewall service for the changes to take effect.

sudo firewall-cmd --reload

Test The Virtual Hosts

Now on the desktop Linux computer, open your web browser and go to the URLs http://192.168.1.42:80 and http://192.168.1.43:8080.

Add a comment
Know the answer?
Add Answer to:
what command can I (i'm not a root) use to create Virtual host entry that should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A virtual host can be set up by using the following except: Question options: IP port...

    A virtual host can be set up by using the following except: Question options: IP port protocol Which Apache 2 directive defines the default page served in a directory? Question options: DocumentRoot DirectoryIndex Alias Which of the following statement is incorrect? Question options: PHP is installed as an Apache module. phpmyadmin cannot be used if the web server is not started. The Linux root account is by default the admin user for MySQL.

  • Description: In this project, you are asked to install virtualization software on a host computer, install...

    Description: In this project, you are asked to install virtualization software on a host computer, install guest operating system on the virtual machine, and finally set up a web server in the guest operating system. Host Operating System: Your host operating system can be any operating system you are familiar with and have access to. Virtualization Software: VMWare Workstation Player or VirtualBox Guest Operating System: Ubuntu Web Server: Apache Steps: 1. Install Virtualization software a. VMWare Player i. Free download...

  • Create a variable $a and assign it a value of 3 then use the write-host command...

    Create a variable $a and assign it a value of 3 then use the write-host command to display the value. Write a command to find the type of variable $a. Create a variable $myname with your firstname and surname in it. Use the pipe symbol and gm to work out what methods are available to make it all uppercase or lowercase. Write a command that displays only the services that are running. Write a command that displays only the services...

  • For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would...

    For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. 16. What command could I run to determine whether the ssh daemon is listening? With OpenSSH installed and running, the result should show that ssh/port 22 as "listening.' (5 pts) 17. Create a crontab entry that...

  • I'm trying to understand how a bot can communicate with command and control (CC) machine. On...

    I'm trying to understand how a bot can communicate with command and control (CC) machine. On a technical level, I know bots use sockets (for example), but I really have no idea how the CC can send commands to a bot/computer which is probably inside a LAN private network. Lots of computers are in a LAN behind a box, or a router. So for communication behind a port with a server you must to use NAT I think. Can anyone...

  • My dream is to study at MIT, however, I think I'm not knowledgable enough. What should...

    My dream is to study at MIT, however, I think I'm not knowledgable enough. What should I do, what steps should I take, or what should I study in order to be accepted? I'm from an Asian country. and currently, I'm studying for a Master's degree in Computer Science. I'm planning to have my PhD studies there.

  • what it is the difference between these commands? what command would I use to create an...

    what it is the difference between these commands? what command would I use to create an array that spans between 5 and 25 and is equispaced into four intervals? command 1: x= 5:5:25 command 2: x =linespace(5,25,4)

  • Scenario 2 (Use the network 192.126.100.0 for the following questions.) 9) I want to break up...

    Scenario 2 (Use the network 192.126.100.0 for the following questions.) 9) I want to break up my network into subnets for some workgroups. Each workgroup has 12 hosts, what is the maximum # of subnets can I create that will support at least 12 hosts per subnet? 10) What will the subnet mask be? 11) Give the network, IP range, and broadcast address for the first 3 networks: Network 1: Broadcast: Host IP Range: to Network 2: Broadcast: Host IP...

  • Please explain with mechanism I'm so confused what mechanism I should have to use. Part III...

    Please explain with mechanism I'm so confused what mechanism I should have to use. Part III - Mechanism (14 marks] A. Use the curved arrow notation to draw the step-wise reaction mechanisms that account for the formation of the products shown in the transformation below. All reactants are shown. (8 MARKS] MeOH осна + -TsOH

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT