Configure Apache Virtual Host and apache Virtual Host

Source: Internet
Author: User

Configure Apache Virtual Host and apache Virtual Host

1. install apache

[Root @ server03 etc] # yum install httpd

Ii. Configuration

[Root @ server03 etc] # cd/var/www/html

Create a webpage

[Root @ server03 html] # vim index.html

Enable Service

[Root @ server03 html] # service httpd start

Enter the local ip address in the browser to view the edited webpage.

Open the Apache configuration file

[Root @ server03 html] # vim/etc/httpd/conf/httpd. conf

Edit 262nd actions:

ServerAdmin root@server03.example.com

Remove 990 lines of comments

To the end

Changed:

<VirtualHost *: 80>

DocumentRoot/var/www/vmhost

ServerName vmhost03.example.com

</VirtualHost>

 

[Root @ server03 html] # cd ..

[Root @ server03 www] # mkdir vmhost

[Root @ server03 www] # cd vmhost/

[Root @ server03 vmhost] # vim index.html

Content: vmhost

[Root @ server03 vmhost] # service httpd restart

Stopping httpd: [OK]

Starting httpd: [OK]

Enter the local ip address in the browser to view the vmhost.

 

[Root @ server03 vmhost] # vim/var/named/chroot/var/named/example.com. zone

Add:

Vmhost03 in a 192.168.4.103

Restart apache

Restart DNS

Open the browser and enter vmhost03.Example.com to view the vmhost.

 

Enter server03.Example.com and you will see the vmhost.

Open the Apache configuration file:

[Root @ server03 vmhost] # vim/etc/httpd/conf/httpd. conf

Add:

<VirtualHost *: 80>

DocumentRoot/var/www/html

ServerName server03.example.com

</VirtualHost>

Save and restart Apache

Enter server03.Example.com in the browser. The value is 12345.

Enter vmhost03.Example.com to view the vmhost.

 

Under/var/www/html

[Root @ server03 Desktop] # cd/var/www/html

[Root @ server03 html] # mkdir virtual

[Root @ server03 html] # cd virtual

[Root @ server03 virtual] # vim index.html

The content is virtual.

Save and exit

 

Open the Apache configuration file

[Root @ server03 vmhost] # vim/etc/httpd/conf/httpd. conf

Modify Directory Access Control in Row 3

Changed:

Alias/virtual "/var/www/html/virtual"

 

<Directory "/var/www/html/virtual">

Options Indexes MultiViews FollowSymLinks

AllowOverride None

Order allow, deny

Allow from 192.168.4.103

Deny from all

</Directory>

Save and restart Apache

Open your browser and enter

192.168.4.103/virtual

Appears:

Forbidden

 

You don't have permission to access/virtual on this server.

Apache/2.2.15 (Red Hat) Server at 192.168.4.103 Port 80

 

Description

Deny from all works. Other users cannot access

Open the Apache configuration file and comment Deny from all in line 3. Save and exit.

Restart Apache

Enter 192.168.4.103/virtual in the browser and you can access it again.

Disable the server firewall and open another virtual machine in the same network segment.

Enter 192.168.4.103/virtual in the browser to see Forbidden

It means that only the local machine can access other hosts and cannot access

Open the Apache configuration file to modify the 550 behavior:

 

Alias/virtual "/var/www/virtual"

 

<Directory "/var/www/virtual">

Options Indexes MultiViews FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

</Directory>

 

[Root @ server03 vmhost] # cd/var/www/

[Root @ server03 www] # mv html/virtual ./

 

Restart Apache

Access http: // 192.168.4.103/virtual/

In this way, you can access things other than html.


How does Apache configure multiple virtual hosts?

I hope to help you with this tutorial...
Reference: www.chinahost.org/page-979-1-1.html? Fa = bd_Ap

How does Apache configure multiple virtual hosts?

I hope to help you with this tutorial...
Reference: www.chinahost.org/page-979-1-1.html? Fa = bd_Ap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.