Implementation of virtual domain names in Linux (3)

Source: Internet
Author: User
Article title: implementation of virtual domain names in Linux (3 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: Zheng Tao/ASPCool
III. CGI program compilation
To apply for a virtual domain name online, you must write the corresponding CGI program to dynamically modify the independent configuration file (the above vhostdbm file) and manage users (including user application, login, password change ). This section only describes operations on independent configuration files. For more information about how to write CGI programs in Perl, see.
The vhostdbm file uses the dbm format to record data. Compared with common text files, the file search speed is faster and easier to modify. Many UNIX systems have a standard library called database management. This database stores a set of key-value pairs in a pair of disk files. It provides a simple database management tool to conveniently change, add, or delete data content.
Perl accesses dbm by connecting the associated array to the dbm database through a process similar to opening a file. When a new element is created in the array, the dbm database is changed immediately. Deleting an element also deletes the values in the dbm database. Available:
1. to associate a dbm database with a dbm array:
Dbmopen (% arrayname, "dbmfilename", $ mode );
If dbmfilename does not exist, create the database. The % arrayname parameter is an associated array of Perl (if the array already has values, these values will be deleted ). The joined array is connected to the dbm database called dbmfilename. $ Mode is the number used to control the permission of the database file when a database needs to be created. this number is specified in the 8 format and is often used in the 0644 format, read-only permissions are granted to new users except the host. the host has all permissions.
2. close the dbm database:
Dbmclose (% arrayname );
% Arrayname is the array name associated with the dbm database.
Example 6: open vhostdbm in VHOST or create a new dbm database:
Dbmopen (% VHOST, "vhostdbm", 0644 );
Example 7: create a record or change an existing record (set the parameter names from the html file form to vhost and rhost ):
$ VHOST {$ FORM {'vhost' }}=$ FORM {'rhost '};
Example 8: delete an existing record (set the parameter name from the html file form to vhost ):
Delete $ VHOST {$ FORM {'vhost '}};
Example 9. disable vhostdbm:
Dbmclose (% VHOST );
Note: If the input parameters have been verified, there are no duplicate records. Otherwise, the existing records may be confused.
  
  
  
Related Article

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.