Apache Build Web Host (virtual directory, IP address, port, host name, respectively)

Source: Internet
Author: User
Tags dnssec web hosting

Apache Introduction

Apache HTTP Server is an open-source Web services software that maintains over half of the Web server space, and Apache servers can run on most operating system platforms such as Linux, UNIX, and Windows.

Apache server performance in terms of functionality, performance and security are more prominent, can better meet the needs of Web server users, and its main features include the following aspects:

    • Open Source Code
    • Cross-platform applications
    • Supports a variety of Web programming languages
    • Modular design
    • Very stable operation
    • Good security
Building a virtual web host

Running multiple Web sites in the same Apache server, each of which does not actually occupy the entire server, can make full use of the server's hardware resources through the virtual web hosting service, which greatly reduces the cost of building and running the site.

Apache supports the following three types of virtual hosts:
    1. Based on IP address

You need to use a different domain name for each virtual host, and the corresponding IP address is not the same. This approach requires the server to be equipped with multiple network interfaces, so the application is not very extensive;

    1. Based on IP port

Different TCP port numbers are used to differentiate different site content, but users need to specify a port number to access the different virtual sites;

    1. Based on host name "common"

Each virtual host uses a different domain name, but its corresponding IP address is the same;

Experimental environment
    • rhel6.5 Operating System
    • Server IP Address: 192.168.100.5
    • rhel6.5 mirrored disc mounted to/mnt/cdrom/
Experimental content
    1. Virtual directory (user authorization limit)
    2. Based on IP address
    3. Based on IP port
    4. Based on host name "common"
Deployment Services Install Apache Server (httpd)

1. Check and install the HTTPD service

[[email protected] ~]# rpm-q httpd//Check if HTTPD is installed
Httpd-2.2.15-29.el6_4.x86_64
[Email protected] ~]# rpm-ivh/mnt/cdrom/packages/httpd-2.2.15-29.el6_4.x86_64.rpm

2. Turn off security settings and firewalls

Setenforce 0
Service Iptables Stop

I. Virtual directory (user authorization limit)
    1. Edit httpd.conf configuration file
vim /etc/httpd/conf/httpd.conf

ServerName www.yum01.com:80//Set host name
Listen 192.168.100.5:80//Setting the Listening IP address
Include conf.d/*.conf//Open load CONF.D directory with. conf as the suffix of the configuration file

    1. Create a new vdir.conf (virtual directory file) under the/etc/httpd/conf.d/directory
cd /etc/httpd/conf.d/vim vdir.conf                       //新建vdir.conf配置文件

The following is a virtual directory definition configuration file

Alias/bbs "/opt/bbs/"//Set Alias

<directory "/opt/bbs/" >//define Virtual directory
Options Indexes multiviews FollowSymLinks
AllowOverride None
AuthName "Auth Directory"//Certification Domain name
AuthType Basic//Fundamental authentication method
Authuserfile/etc/httpd/user//Basic Authentication user account, password Authentication file path
Require Valid-user//authorized users can access
</Directory>

3. Create the/opt/bbs directory and new BBS site homepage

Mkdir/opt/bbs
echo "

    1. Create a user authentication data file
htpasswd -c /etc/httpd/conf.d/user zhangsan

    1. Restart HTTPD Service
      service httpd restart
Test

Server IP Information:

Client Ping Server test:

To access the virtual directory site:

2. Based on IP address

Cond...

3. Port-based
    1. Create a new vport.conf (virtual directory file) under the/etc/httpd/conf.d/directory
cd /etc/httpd/conf.d/vim vport.conf                       //新建vport.conf配置文件

Namevirtualhost 192.168.100.5:80//Virtual host name

<virtualhost 192.168.100.5:80>
ServerAdmin [email protected]//admin mailbox
DOCUMENTROOT/OPT/YUN01///Site Directory
ServerName www.yun01.com//Domain name
Errorlog logs/yun01.com-error_log//error log
Customlog Logs/yun01.com-access_log common//access log
</VirtualHost>

Namevirtualhost 192.168.100.5:81//Virtual host name

<virtualhost 192.168.100.5:81>
ServerAdmin [email protected]//admin mailbox
documentroot/opt/yun02///Site Directory
ServerName www.yun02.com//Domain name
Errorlog logs/yun02.com-error_log//error log
Customlog Logs/yun02.com-access_log common//access log
</VirtualHost>

2. Create/opt/yun01,/opt/yun02 Site Directory, and new site home page file (index.html)

MKDIR/OPT/YUN01/OPT/YUN02//Create a Site Directory
echo "echo "

    1. Modifying the httpd.conf configuration file
vim /etc/httpd/conf/httpd.conf

Listen 192.168.100.5:81//Add 81-Port listening address

    1. Restart HTTPD Service
service httpd restart
Test

Visit 192.168.100.5:80

Visit 192.168.100.5:81

4. Based on host name "common"
    1. Create a new vhost.conf (virtual directory file) under the/etc/httpd/conf.d/directory
cd /etc/httpd/conf.d/vim vhost.conf                       //新建vhost.conf配置文件

Namevirtualhost 192.168.100.5:80//Virtual host name

<virtualhost 192.168.100.5:80>
ServerAdmin [email protected]//admin mailbox
DOCUMENTROOT/OPT/YUN03///Site Directory
ServerName www.yun03.com//Domain name
Errorlog logs/yun03.com-error_log//error log
Customlog Logs/yun03.com-access_log common//access log
</VirtualHost>

Namevirtualhost 192.168.100.5:80//Virtual host name

<virtualhost 192.168.100.5:80>
ServerAdmin [email protected]//admin mailbox
DOCUMENTROOT/OPT/YUN04///Site Directory
ServerName www.yun04.com//Domain name
Errorlog logs/yun04.com-error_log//error log
Customlog Logs/yun04.com-access_log common//access log
</VirtualHost>

2. Create/OPT/YUN03,/opt/yun04 Site Directory, and new site home page file (index.html)

MKDIR/OPT/YUN03/OPT/YUN04//Create a Site Directory
echo "echo "

    1. Installing a DNS server
      3.1 Installing the BIND package
rpm -ivh /mnt/cdrom/Packages/bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm

3.2 Editing the master configuration file

 vim /etc/named.conf

Options {
Listen-on Port 53 {192.168.100.5;}; Modify the specified listening IP
Listen-on-v6 Port 53 {:: 1;};
Directory "/var/named";
Dump-file "/var/named/data/cache_dump.db";
Statistics-file "/var/named/data/named_stats.txt";
Memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query {any;}; Allow any (Everyone) access
recursion Yes;

Dnssec-enable Yes;
Dnssec-validation Yes;
Dnssec-lookaside Auto;

/ Path to ISC DLV key /
Bindkeys-file "/etc/named.iscdlv.key";

Managed-keys-directory "/var/named/dynamic";
};

3.3 Editing a zone configuration file

vim /etc/named.rfc1912.zones

Zone "Yun03.com" in {
Type master;
File "Yun03.com.zone";
};

Zone "Yun04.com" in {
Type master;
File "Yun04.com.zone";
};

3.4 Switch to the/var/named directory

cd /var/named

3.5 Copying template files

cp -p named.localhost yun03.com.zone

3.6 Editing a zone data configuration file

vim yun03.com.zone

Because the yun04.com and yun03.com parse files are the same, copy the Yun03.com.zone file directly here

cp -p yun03.com.zone yun04.com.zone

3.7 Join the named service and restart the service

Chkconfig named on
Service named restart//restart named services
Service httpd restart//restart HTTPD services

Test

Visit www.yun03.com

Visit www.yun04.com

Apache Build Web Host (virtual directory, IP address, port, host name, respectively)

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.