Shell script Practice Notes (5) -- build an image server for resources

Source: Internet
Author: User

Background:
Access to Site Resources outside China is sometimes very slow. an occasional download is certainly tolerable. It is a wise decision to build an image site for multiple use or internal use by a small team.
This section uses the yum source image of cdh5 as an example to describe how to use apache2 to build a directory image service and how to copy Site Resources.

1) Build an apache2 server
*) Install apache2.
Yum install httpd
Yum info httpd

*) Confirm configuration items
/Etc/httpd/CONF/httpd. conf

DocumentRoot "/var/www/html"

This configuration item is the default root directory of apache2.

The corresponding DocumentRoot directory structure is as follows:

*) The service is enabled.
Service httpd status
Service httpd start

*) Service verification
Netstat-NLP | grep-e ": 80 \ s"

Browser access

 

2) create an Access Directory
Two methods:
1). under DocumentRoot, create a file/soft link.
Here, we will create a soft link as an example:
Mkdir-P ~ /Resource
Touch ~ /Resource/hive.txt ~ /Resource/hbase.txt
Ln-S ~ /Resource/var/www/html/Resource
Access http: // 172.16.1.106/Resource

2). Build new directory labels
*) Edit/etc/httpd/CONF/httpd. conf.

Alias /repo "/var/www/repo" <Directory "/var/www/repo">  Options Indexes MultiViews FollowSymLinks   AllowOverride None  Order allow,deny  Allow from all</Directory>

Use the alias command to make directory:/var/www/repo correspond to/repo in URL

Indexes: Allows display in directory structure. followsymlinks: allows the use of soft links in this directory.

To enable the URL to display the directory structure, the contents of index.html will be removed from the directory, and the content of index.html will be displayed on the negative side, depending on the definition.

DirectoryIndex index.html index.html.var

*) Construct related directories and files
Mkdir-P/var/www/Repo
Touch/var/www/repo/repo.txt

*) Access Verification
Access http: // 172.16.1.106/Repo

3). Copy the site
*) Recursively downloads Site Resources
Http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.0.1/
Http://archive-primary.cloudera.com/cdh5/redhat/5/x86_64/cdh/5.0.1/

Cd ~ /Resource
Wget-c-r-NP http://archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.0.1/
Wget-c-r-NP http://archive-primary.cloudera.com/cdh5/redhat/5/x86_64/cdh/5.0.1/

*) Install createrepo
Yum install createrepo

*) Repodata Reconstruction
Createrepo ~ /Resource/archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.0.1/
Createrepo ~ /Resource/archive-primary.cloudera.com/cdh5/redhat/5/x86_64/cdh/5.0.1/

*) Create a soft link
Ln-S ~ /Resource/archive-primary.cloudera.com/cm5/redhat/5/x86_64/cm/5.0.1// var/www/repo/cm5
Ln-S ~ /Resource/archive-primary.cloudera.com/cdh5/redhat/5/x86_64/cdh/5.0.1// var/www/repo/cdh5

*) Verification

References:
Apache2 configuration details
Http://liudaoru.iteye.com/blog/336338
Http://jingyan.baidu.com/article/9158e0006581d1a2541228b5.html

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.