CRAN Mirror HOWTO/FAQ

This page explains how to create a new CRAN mirror, which is fairly simple. If you would like to become an official CRAN mirror, please be sure to read and follow these instructions carefully. You should have the consent of your hosting company (if you aren't a hosting company yourself), and be prepared for some reasonably significant bandwidth usage. The full size of CRAN was approx 120GB on 2012-10-16 (and we are growing all the time).

We currently have no written set of rules when we accept a new mirror into the official list. PHP accepts only up to two mirrors per country, we think there may be need to treat China different from, say, Luxembourg. So use common sense and ask yourself whether your mirror helps the R community. We want good global coverage, but also short lists on the mirror webpage or in a GUI. In addition, human time is involved in maintaining the list and monitoring it. If there is no mirror in your country, it will usually accepted. Otherwise ask first if in doubt.

Where do I get a copy of CRAN?

The CRAN master site at WU Wien, Austria, can be found at the URLs
http://cran.r-project.org
ftp://cran.r-project.org/pub/R/
rsync: cran.r-project.org::CRAN
All you have to do is recursively mirror the complete tree to your webserver on a regular basis (at least twice a week, better every 1-2 days, but not more than twice a day). Which software you use for mirroring depends on the operating system of your server, but we strongly recommend that you use rsync. You may want to call it using the following arguments:
 rsync -rtlzv --delete cran.r-project.org::CRAN /dir/on/local/disc 
Do not forget the --delete flag to remove files from the mirror that are no longer present on the master.

Server configuration

CRAN contains no dynamic pages, so no special configuration of your web server is needed. The only exception is that files with extension .shtml need to be recognised as HTML pages, but that is the default for most server software anyway. The main frame of the CRAN top page banner.shtml has this extension, so you will immediately see it in case something is wrong.

If you use the Apache web server and want to promote the hosting institution of the mirror you may want to add something like

  SetEnv CRAN_HOST "This server is hosted by bla bla bla ..."
to your Apache configuration. The string "This server ..." (which may contain HTML markup) will be added in the footer of the CRAN top page, see the main server for an example. You also need something like
  #
  # To use server-parsed HTML files
  #
  AddType text/html .shtml
  AddHandler server-parsed .shtml
in the MIME-types section of the Apache configuration, the exact syntax depends on the version of Apache. All you have to do is uncomment these (or similar) lines in the default configuration.

Furthermore, it is necessary that your web server is configured to allow redirections. You need this to enable redirection to package web pages. E.g.,

http://cran.r-project.org/package=foo
redirects to
http://cran.r-project.org/web/packages/foo/index.html
The same also is possible for task views:
http://cran.r-project.org/view=bar
If you use the Apache web server this feature can be enabled by loading the mod_rewrite module. A .htaccess file (typically synced with the CRAN mirror) in CRAN's root directory does the rest of the configuration. If this last step fails for some reason (e.g., you do not allow .htaccess files, which is the default since Apache 2.4) then you have to add the following lines to your Apache configuration:
RewriteEngine on
RewriteRule ^package=(.+) /web/packages/$1/index.html [R=seeother]
RewriteRule ^view=(.+) /web/views/$1.html [R=seeother]

Apache version 2.4 and newer does not recognise the syntax used in banner.shtml and allow the use of .htaccess files by default. The previously mentioned .htaccess file also enables the syntax in banner.shtml to be recognised and in order to use it, change your Apache Configuration to:

AllowOverride All
If this last step fails, or you do not want to allow .htaccess files, then you have to add the following line to your Apache configuration, similar to the Rewrite Rules:
SSILegacyExprParser on

Inform us!

Once your mirror is up and running and the automatic updates work for a couple of days send email to cran@r-project.org such that we can include your site in the list of mirrors. Please include the following information in your email:

Thanks in advance for providing webspace for the R Project!


Last modified: October 7, 2014 by Markus Mayer