Developing "virtual domain Name" system with PHP programming

Source: Internet
Author: User
Tags bind php programming name database

If your own server can also implement denoted domain name is good. It's not complicated, actually. You can also do a denoted domain Name System.

The key technology of denoted domain Name System lies in: Implementing the redirection of Web pages (redirctory). In essence, the denoted domain Name system is completely different from the virtual machine system. The virtual domain name and IP of the virtual machine exist one by one correspondence. The denoted domain Name system does not need to do one by one mapping domain names and IP. That is, it doesn't require a complex domain name resolution mechanism or a virtual machine, and it does what it does when you request Yourname.somedomain, redirecting your browser to where you originally stored the HTML page.

The operating environment of this program is: RedHat 5.1 Linux under the Apache1.3.6 Web server PHP3 language. Before we write a program, we need to set up our servers first. First, let the Apache server support PHP3. To ftp.redhat.com download mod_php-2.0.1-9.i386.rpm, after installation, modify/etc/httpd/conf/http.conf file, remove #loadmodule php3_module a line in front of the # annotation number, Also in the/etc/httpd/conf/srm.conf file, remove the #addtype application/x-httpd-php3. PhP3, and add DirectoryIndex after the INDEX.PHP3 item. Restart Apache server, at which point the server supports standard PHP3 language script files and can use INDEX.PHP3 as the default home page.

Set up the DNS server so that it can resolve the generic domain name. Common UNIX and Linux system DNS resolution is done by the bind daemon, Bind4 and Bind8 configuration files/etc/named.boot and name.conf respectively, configured according to your system changes. Set the configuration file for Bind/etc/named.boot, in which you add the phrase "primary domain.com Db.domain", adding a new domain record. Add in/etc/name.conf:

Zone "domain.com" {

Type master;

File "Db.domain"; };

Create a new primary domain record file Db.domain in/var/name/in the format:

N SOA dns.domain.com root.domain.com (

199811291; Serial

28800 refresh;

7200; retry.

604800; expire.

86400); minimum

Dns

MX Ten dns.domain.com.

DNS A 202.115.135.50

www A 202.115.135.50

* A 202.115.135.50

The key is the last sentence, and all hostname that may be unmarked in the entire domain will point to the same IP. Perform/USR/SBIN/NDC reload and reload the domain name database. Test, at this time should be ping a domain of the host (except already marked), all point to the specified IP, then the DNS server settings completed.

The final step is to compile the PHP3 script. We have just explained the whole principle in the diagram, so it is not very difficult to write a redirect program.

Let's look at a complete HTTP header message sent by IE5.0:

Accept:application/vnd.ms-excel, Application/msword, Application/vnd.ms-powerpoint,image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, */*

Accept-encoding:gzip, deflate

Accept-language:zh-cn

Connection:keep-alive

Host:ww.yahoo.com

  user-agent:mozilla/4.0 (compatible; MSIE 5.0b1; Windows 98)

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.