Apache virtual directory different host name different port

Source: Internet
Author: User

experimental Environment: RHEL6 as server, host or another win system for the access terminal
Experimental Purpose: To achieve multi-channel Web Access
Experimental Requirements: Server IP address: 192.168.100.10 IP Address: 192.168.100.25 (as long as the 100 segment of the line)

1. First install the HTTPD service, enter the configuration file to configure
Vim/etc/httpd/conf/httpd.conf
Listen 192.168.100.10:80//Listening port
#Listen//ipv6 Write off
ServerName www.benet.com:80//host Name

2. Service httpd start//Open Services
Service Iptables Stop//
Setenforce 0//Shut down the firewall

At this point, you can access the Apache browser input 192.168.100.10 can see the homepage

3. Customize the page content and restart the service

4. Visit Apache again to see the custom content

5. Now let's add the virtual user
First go to the directory where the configuration is located cd/etc/httpd/conf.d
Vim vdir.conf//Create a configuration file

Alias/test "/opt/test/"//define a name, physically stored in OPT

<directory "/opt/test/" >//define Physical path
Options Indexes multiviews followsymlinks//Build an index
AllowOverride None//First two behaviors default fixed format, no Override allowed
AuthName "Hello"//iconic information
AuthType Basic//authentication type, Basic authentication
Authuserfile/etc/httpd/user//Authentication account file
Authgroupfile/etc/httpd/group//Authentication Group
Require Valid-user//enable user authentication
Require user test//Only allow users to log in
Require Group admin//Allow only groups to log on
</Directory>

6. Mkdir/opt/test//Create a file in opt to be the same as above
echo "This is VDir Test" >/opt/test/index.html//define a Web page file

7. Htpasswd-c/etc/httpd/user li//create an Li user
Service httpd restart//Restart services

8. Browser input 192.168.100.10/test into the test
Then you need to enter the user and password to access the Web page

9. The following sets different host name access
Vim host.conf

Namevirtualhost 192.168.100.10:80//Specify an IP address and a corresponding port
<virtualhost 192.168.100.10:80>//
ServerAdmin [email protected]//Create an admin mailbox
documentroot/opt/benet///define the Site Directory
ServerName www.benet.com//server name
Errorlog Logs/benet.com-error_log//Two logs, error log
Customlog Logs/benet.com-access_log common//access log
</VirtualHost>

<virtualhost 192.168.100.10:80>
ServerAdmin [email protected]
documentroot/opt/accp/
ServerName www.accp.com
Errorlog Logs/accp.com-error_log
Customlog Logs/accp.com-access_log Common
</VirtualHost>//define another Web page

Mkdir/opt/benet//Create File
MKDIR/OPT/ACCP//
echo "This is Benet" >/opt/benet/index.html//Definition page
echo "This is ACCP" >/opt/accp/index.html//

rpm-ivh/mnt/packages/bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm//dns Analysis

Vim/etc/named.conf.
Listen-on Port 53 {192.168.100.10;}; Listening port
....
allow-query {any;}; Allow All Access

13. Vim/etc/named.rfc1912.zones
Zone "Benet.com" in {//parse benet.com
Type master;
File "Benet.com.zone"; Working paper for Benet.com.zone
allow-update {none;};
};

zone "accp.com" IN {    //    type master;    file "accp.com.zone";   //    allow-update { none; };};

cd/var/named/.
Cp-p Named.localhost Benet.com.zone
Vim Benet.com.zone
@ in SOA @ admin.benet.com. (//Administrator host name
0; Serial
1D; Refresh
1H; Retry
1W; Expire
3H); Minimum
NS @
A 192.168.100.10
www in A 192.168.100.10//Parse URL
Same set ACCP

Service named start
Service httpd restart//Open Services

Browser Test www.benet.com www.accp.com

16. Different port tests are performed below
Vim/etc/httpd/conf.d/host.conf
At the bottom of the add
Namevirtualhost 192.168.100.10:8080
<virtualhost 192.168.100.10:8080>
ServerAdmin [email protected]
documentroot/opt/benet01/
ServerName www.benet.com
Errorlog Logs/benet.com-error_log
Customlog Logs/benet.com-access_log Common
</VirtualHost>

Cd/etc/httpd/conf.d/.
mkdir/opt/benet01
echo "This is benet8080" >/opt/benet01/index.html//define Web content

18. Vim/etc/httpd/conf/httpd.conf
Listen 192.168.100.10:80
Listen 192.168.100.10:8080//monitor 8080 port
#Listen 80

18. Service httpd restart//Restart services
Browser input 192.168.100.10:8080

Test complete

Apache virtual directory different host name different port

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.