Mirroring The PHP Website

The PHP project does not have an official mirror program anymore, but you can set-up a mirror for your own network or company.

You should not synchronize from our network more frequently than once every six hours, or you may find your IP blocked. Also, please make an effort to only mirror those parts of the site that you actually need. (For example, exclude the manual in all languages that you will not be using and exclude the distributions directory.)

Get Files With Rsync

First, you need to have a rsync installed. To synchronize your server with the appropriate rsync location, first view the coverage map and identify which location your mirror should be using. Next, modify the following code for use with your mirror. Replace YOUR_RRN_HOSTNAME with your RRN's hostname as indicated by the coverage map and be sure to change /your/local/path with the path to where your php.net mirror will reside on the filesystem.

    rsync -avzC --timeout=600 --delete --delete-after \
      --include='distributions/*.exe' \
      YOUR_RRN_HOSTNAME::phpweb /your/local/path

If you only want to mirror mirror one language of the manual? Add:

    --include='manual/en/' --include='manual/en/**' --exclude='manual/**' --exclude='distributions/manual/**'

after "--delete-after" in the command line above (substituting your prefered language code in place of 'en'). You can also exclude the whole distributions directory (and the related extra folder) by replacing "--exclude='distributions/manual/**'" with "--exclude='distributions/**' --exclude='extra/**'".

PHP mirror sites should provide the exact content coming from our servers, and must not be altered in any way unless explicitly stated in the mirroring guidelines. Failing to do will result in immediate termination and permanent expulsion of your participation in the program.

Add SQLite 3 Support

SQLite is an embedded SQL database implementation that has very high performance for applications with low write concurrency. PHP mirrors can currently employ SQLite for URL shortcut lookups.

There are a couple of SQLite 3 implementations in PHP. One is via the PDO extension by using the SQLite driver (pdo_sqlite, which is required). The other is via the SQLite3 extension. These extensions are both compiled into PHP by default. Note: Some Linux distributions disable many extensions in their package systems, including SQLite. Please make sure you install the "php5-sqlite" (or similar) package if using such a system.

Setup Apache VirtualHost

Make sure your web server is set up to serve .php files as PHP parsed files. If it isn't, add the MIME type to your config.

Please make sure you have turned off output compression for binary files.

Create a VirtualHost entry, which looks something like:

<VirtualHost *-or-your-hostname-or-your-ip-here>
     <Directory /www/htdocs/phpweb>
          # Do not display directory listings if index is not present,
          # and do not try to match filenames if extension is omitted
          Options -Indexes -MultiViews

     ServerName mymirror.example.com
     ServerAdmin yourname@example.com
     UseCanonicalName On

     # Webroot of PHP mirror site
     DocumentRoot /www/htdocs/phpweb

     # Log server activity
     ErrorLog logs/error_log
     TransferLog logs/access_log

     # Set directory index
     DirectoryIndex index.php index.html

     # Handle errors with local error handler script
     ErrorDocument 401 /error.php
     ErrorDocument 403 /error.php
     ErrorDocument 404 /error.php

     # Add types not specified by Apache by default
     AddType application/octet-stream .chm .bz2 .tgz .msi
     AddType application/x-pilot .prc .pdb

     # Set mirror's preferred language here
     SetEnv MIRROR_LANGUAGE "en"

     # The next two lines are only necessary if generating
     # stats (see below), otherwise you should comment them out
     Alias /stats/ /path/to/local/stats/
     SetEnv MIRROR_STATS 1

     # Apache2 has 'AddHandler type-map var' enabled by default.
     # Remove the comment sign on the line below if you have it enabled.
     # RemoveHandler var

     # Turn spelling support off (which would break URL shortcuts)
     <IfModule mod_speling.c>
       CheckSpelling Off

     # A few recommended PHP directives
     php_flag display_errors off

     # If you have Russian Apache with mod_charset installed,
     # do not forget to search for this line in your existing
     # configuration, and comment it out:
     # AddHandler strip-meta-http .htm .html


When setting up the vhost, provide an asterisk, a hostname, or an IP address in the VirtualHost container's header (depending on whether you would like to make the vhost work for all IPs handled by Apache, or just a specific hostname/IP address). Consult the Apache documentation for the differences of the two methods.

Change the DocumentRoot setting as appropriate, specify the mirror's preferred language, and provide settings according to your stats setup, if your mirror is going to provide stats. For the preferred language setting, choose one from those available as manual translations. If you provide something else, your default language will be English. After you restart Apache, your mirror site should start working.

Setting Up Local Stats

Setting up local stats can be a plus on your mirror. We provide some setup instructions for that.

Setup Regular Updates

You must also set up a cron job that periodically does an rsync to refresh your web directory. We prefer that all mirrors update from the appropriate RRN from the coverage map not more than once an hour, to speed up the distribution of updates to the site and available packages. Something like:

   5 * * * * rsync -avzC --timeout=600 --delete --delete-after --include='distributions/*.exe' YOUR_RRN_HOSTNAME::phpweb /your/local/path

Remember to specify the same rsync parameters you used to get the phpweb files as explained near the top of this page. If you're unable to synchronize every five minutes, you may pick your own update frequency, provided it does not exceed fifteen minutes.

Sponsor Logo

We would like to thank you for providing a mirror, so if you would like to display a logo on the mirror site promoting your company, you are able to do so by following these steps:

The PHP Group and the Network Infrastructure Manager reserve the right to refuse images based on content, but most things should be fine.

We have chosen a banner size which conforms with the Internet Advertising Bureau standards.

And finally, don't forget to put a nice little PHP logo somewhere on your hosting company's site if possible. Grab one of the logos from the logos download page, and link it to your mirror. This shows the community that you are a proud supporter of PHP and open source technology.

Mirror Setup Troubleshooting

The mirror troubleshooting guide contains information about the common and potential problems discovered when setting up and maintaining a PHP.net mirror. Included are links that perform many of the tests executed by the automated mirror management tools.

There is a mailing list named "php-mirrors" at lists.php.net, to which you can subscribe. This mailing list is very low-traffic and only used for communication between mirror maintainers and php.net webmasters.

To subscribe send an empty message to: php-mirrors-subscribe@lists.php.net

Thank you for your interest in providing a mirror! If you ever have any questions or concerns, drop us a line at php-mirrors@lists.php.net --- we are here to help!

To Top