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 250 GB on 2019-11-29 (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 be 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

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. For security reasons we furthermore recommend mirroring over an SSH tunnel. You may want to call rsync using the following arguments:

 rsync -e "ssh" -rtlzv --delete /dir/on/local/disc 
or (potentially insecure):
 rsync -rtlzv --delete /dir/on/local/disc 

For rsync over ssh please send your public SSH key to in advance (only requests from organizations are considered) and do not forget the --delete flag to remove files from the mirror that are no longer present on the master.

The CRAN tree uses symbolic links, and so rysnc may not work as expected on a Windows server. It may be necessary to replace -l by -L in the above (and this will also be necessary for some partial mirrors, e.g., those excluding the contrib/Archive area).

Server configuration

CRAN contains no dynamic pages, so in general no special configuration of your web server is needed. However, there are few additional settings and some settings to check.

❏ Display the common index files (usually the default setting).

❏ Files with extension .shtml need to be recognised as HTML pages (usually the default setting). The main frame of the CRAN top page banner.shtml has this extension, so you will immediately see it in case something is wrong.

❏ Generate listings of the directories in /src and in /bin.

For Apache servers, if .htaccess files in the cran directory are enabled (will slow down your server), it should work automatically. Alternatively (recommended) add the following to the apache configuration.

<Directory [your cran directory]/src>
        Options +Indexes

<Directory [your cran directory]/bin>
        Options +Indexes

❏ The following redirections need to work.

[YOUR CRAN MIRROR]/package=foo&version=bar  ➝ [YOUR CRAN MIRROR]/src/contrib/foo_bar.tar.gz IF /src/contrib/foo_bar.tar.gz EXISTS
[YOUR CRAN MIRROR]/package=foo&version=bar  ➝ [YOUR CRAN MIRROR]/src/contrib/Archive/foo/foo_bar.tar.gz IF /src/contrib/Archive/foo/foo_bar.tar.gz EXISTS
[YOUR CRAN MIRROR]/package=foo/bar  ➝ [YOUR CRAN MIRROR]/web/packages/foo/bar
[YOUR CRAN MIRROR]/package=foo  ➝ [YOUR CRAN MIRROR]/web/packages/foo/index.html
[YOUR CRAN MIRROR]/view=bar ➝  [YOUR CRAN MIRROR]/web/views/bar.html

If you use an Apache web server, this feature can be enabled by loading the mod_rewrite module.
→ If you have .htaccess files enabled in the cran directory (not recommended, will slow down your server), and if your mirror lies in the root of your domain, then the rest should work automatically.
→ If you have .htaccess files enabled and your mirror is not in the root of your domain (e.g., then add the following two variables to the apache configuration:

Define CRAN_RewriteBase "/CRAN subpath on your domain/"
Define CRAN_SystemPath "/filepath/"
Define CRAN_RewriteBase "/CRAN/"
Define CRAN_SystemPath "/var/www/CRAN/"
! Note slashes on both sides.

→ If .htaccess files are not enabled (recommended), you may add the following to the cran directory block of your apache configuration.

(goes in the <Directory [your cran directory]> ... </Directory> block)
RewriteEngine on

RewriteBase "/"
# If your mirror lies in a subpath of your domain, use instead: RewriteBase "/subpath/" (e.g. RewriteBase "/CRAN/")

## package=foo&version=bar if current
RewriteCond "%{DOCUMENT_ROOT}/src/contrib/$1_$2.tar.gz" -f
# If your mirror lies in a subpath of your domain, use instead: RewriteCond "/FULL_PATH_TO_CRAN_DIRECTORY/src/contrib/$1_$2.tar.gz" -f
RewriteRule "^package=([^/]+)&version=([^/]+)$" "src/contrib/$1_$2.tar.gz" [R=seeother]

## package=foo&version=bar if in archive
RewriteCond "%{DOCUMENT_ROOT}/src/contrib/Archive/$1/$1_$2.tar.gz" -f
# If your mirror lies in a subpath of your domain, use instead: RewriteCond "/FULL_PATH_TO_CRAN_DIRECTORY/src/contrib/Archive/$1/$1_$2.tar.gz" [R=seeother]
RewriteRule "^package=([^/]+)&version=([^/]+)$" "src/contrib/Archive/$1/$1_$2.tar.gz" [R=seeother]

## package=foo/bar
RewriteRule ^package=([^/]+)/(.+) web/packages/$1/$2 [R=seeother]

## package=foo
RewriteRule ^package=([^/]+) web/packages/$1/index.html [R=seeother]

## view=bar
RewriteRule ^view=([^/]+) web/views/$1.html [R=seeother]

If you would like to promote the hosting institution of the mirror, you can use the environmental variable CRAN_HOST.

In that case, you would need to enable server side includes (without execution). For compatibility reasons the current syntax in banner.shtml is "pre Apache 2.4", so for it to be properly parsed by your server you might also need to include extra compatibility parameters in your configuration (for Apache see below).

If you have an Apache server, here is what you would need to include in your configuration.

  SetEnv CRAN_HOST "This server is hosted by your organization ..."
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 would also need

Options +IncludesNOEXEC
in the corresponding <Directory> section, as also
  # To use server-parsed HTML files
  AddType text/html .shtml
<IfModule mod_include.c>
  AddOutputFilter INCLUDES .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.

As mentioned above, Apache version 2.4 and newer does not recognise the syntax used in banner.shtml. If you have .htaccess files enabled (not recommended) the compatibility configuration is automatically applied. Otherwise add the following to the CRAN Directory block in the Apache configuration.

SSILegacyExprParser on

Inform us!

Once your mirror is up and running and the automatic updates work for a couple of days send email to 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: December 17, 2019 by Gennadiy Starostin