1<?php 2$_SERVER['BASE_PAGE'] = 'mirroring.php'; 3include_once __DIR__ . '/include/prepend.inc'; 4$SIDEBAR_DATA = ' 5<h3>Existing mirror sites</h3> 6<p> 7 Properly working mirror sites are listed on <a href="/mirrors.php">our 8 mirrors page</a>. 9</p> 10'; 11 12site_header( 13 'Mirroring The PHP Website', 14 [ 15 'current' => 'community', 16 'layout_span' => 12, 17 ], 18); 19 20?> 21<h1>Mirroring The PHP Website</h1> 22 23<p> 24 The PHP project does not have an official mirror program anymore, but you can 25 set up a mirror for your own network or company. 26</p> 27 28<p> 29 You should not synchronize from our network more frequently 30 than once every six hours, or you may find your IP blocked. Also, please make 31 an effort to only mirror those parts of the site that you actually need. 32 (For example, <a href="#exclude">exclude the manual in all languages that you 33 will not be using and exclude the distributions directory</a>.) 34</p> 35 36<h2>Get Files With Rsync</h2> 37 38<p> 39 First, you need to have a <a href="http://rsync.samba.org/">rsync</a> 40 installed. 41 To synchronize your server with the appropriate rsync location, first view the <a 42 href="/images/oidk.net-rsync-distribution-plan-may2012.png">coverage map</a> 43 and identify which location your mirror should be using. Next, modify the 44 following code for use with your mirror. Replace <code>YOUR_RRN_HOSTNAME</code> 45 with your RRN's hostname as indicated by the coverage map and be sure to 46 change <code>/your/local/path</code> with the path to where your php.net 47 mirror will reside on the filesystem. 48</p> 49 50<pre class="info"> 51 rsync -avzC --timeout=600 --delete --delete-after \ 52 --include='distributions/*.exe' \ 53 YOUR_RRN_HOSTNAME::phpweb /your/local/path 54</pre> 55 56<a name="exclude"></a> 57<p> 58 If you only want to mirror mirror one language of the manual? Add: 59</p> 60 61<pre class="info"> 62 --include='manual/en/' --include='manual/en/**' --exclude='manual/**' --exclude='distributions/manual/**' 63</pre> 64 65<p> 66 after <code>"--delete-after"</code> in the command line above (substituting your 67 prefered language code in place of <code>'en'</code>). You can also exclude the 68 whole distributions directory (and the related extra folder) by replacing 69 <code>"--exclude='distributions/manual/**'"</code> with 70 <code>"--exclude='distributions/**' --exclude='extra/**'"</code>. 71</p> 72 73<h2>Add SQLite 3 Support</h2> 74 75<p> 76 <a href="http://www.sqlite.org">SQLite</a> is an embedded 77 SQL database implementation that has very high performance for applications 78 with low write concurrency. PHP mirrors can currently employ SQLite for URL 79 shortcut lookups. 80</p> 81 82<p> 83 There are a couple of SQLite 3 implementations in PHP. One is via the 84 PDO extension by using the SQLite driver (pdo_sqlite, which is required). 85 The other is via the SQLite3 extension. These extensions are both compiled 86 into PHP by default. Note: Some Linux distributions disable many extensions 87 in their package systems, including SQLite. Please make sure you install the 88 "php5-sqlite" (or similar) package if using such a system. 89</p> 90 91<h2>Setup Apache VirtualHost</h2> 92 93<p> 94 Make sure your web server is set up to serve <code>.php</code> files as PHP 95 parsed files. If it isn't, add the MIME type to your config. 96</p> 97<p class="warn"> 98 Please make sure you have turned off output compression for binary files. 99</p> 100 101<p> 102 Create a VirtualHost entry, which looks something like: 103</p> 104 105<a name="settings"></a> 106<pre class="info"> 107<VirtualHost *-or-your-hostname-or-your-ip-here> 108 <Directory /www/htdocs/phpweb> 109 # Do not display directory listings if index is not present, 110 # and do not try to match filenames if extension is omitted 111 Options -Indexes -MultiViews 112 </Directory> 113 114 ServerName mymirror.example.com 115 ServerAdmin yourname@example.com 116 UseCanonicalName On 117 118 # Webroot of PHP mirror site 119 DocumentRoot /www/htdocs/phpweb 120 121 # Log server activity 122 ErrorLog logs/error_log 123 TransferLog logs/access_log 124 125 # Set directory index 126 DirectoryIndex index.php index.html 127 128 # Handle errors with local error handler script 129 ErrorDocument 401 /error.php 130 ErrorDocument 403 /error.php 131 ErrorDocument 404 /error.php 132 133 # Add types not specified by Apache by default 134 AddType application/octet-stream .chm .bz2 .tgz .msi 135 AddType application/x-pilot .prc .pdb 136 137 # Set mirror's preferred language here 138 SetEnv MIRROR_LANGUAGE "en" 139 140 # Apache2 has 'AddHandler type-map var' enabled by default. 141 # Remove the comment sign on the line below if you have it enabled. 142 # RemoveHandler var 143 144 # Turn spelling support off (which would break URL shortcuts) 145 <IfModule mod_speling.c> 146 CheckSpelling Off 147 </IfModule> 148 149 # A few recommended PHP directives 150 php_flag display_errors off 151 152 # If you have Russian Apache with mod_charset installed, 153 # do not forget to search for this line in your existing 154 # configuration, and comment it out: 155 # AddHandler strip-meta-http .htm .html 156 157</VirtualHost> 158</pre> 159 160<p> 161 When setting up the vhost, provide an asterisk, a hostname, or an IP 162 address in the VirtualHost container's header (depending on whether 163 you would like to make the vhost work for all IPs handled by Apache, 164 or just a specific hostname/IP address). Consult 165 <a href="http://httpd.apache.org/docs/vhosts/index.html">the Apache 166 documentation</a> for the differences of the two methods. 167</p> 168 169<p> 170 Change the DocumentRoot setting as appropriate, 171 specify the mirror's preferred language, and provide settings according 172 to your stats setup, if your mirror is going to provide stats. For the 173 preferred language setting, choose one from those available as 174 manual translations. If you provide something else, your default 175 language will be English. After you restart Apache, your mirror 176 site should start working. 177</p> 178 179<h2>Setup Regular Updates</h2> 180 181<p> 182 You must also set up a cron job that periodically does an rsync to 183 refresh your web directory. We prefer that all mirrors update from 184 the appropriate RRN from the coverage map not more than once an hour, to 185 speed up the distribution of updates to the site and available packages. 186 Something like: 187</p> 188 189<pre class="info"> 190 5 * * * * rsync -avzC --timeout=600 --delete --delete-after --include='distributions/*.exe' YOUR_RRN_HOSTNAME::phpweb /your/local/path 191</pre> 192 193<p> 194 Remember to specify the same rsync parameters you used to get the 195 <code>phpweb</code> files as explained near the top of this page. 196 If you're unable to synchronize every five minutes, you may pick 197 your own update frequency, provided it does not exceed fifteen 198 minutes. 199</p> 200 201<h2>Mirror Setup Troubleshooting</h2> 202 203<p> 204 The <a href="/mirroring-troubles.php">mirror troubleshooting guide</a> 205 contains information about the common and potential problems discovered 206 when setting up and maintaining a mirror of PHP.net. Included are links that 207 can help demonstrate common configuration problems. 208</p> 209 210<?php site_footer(); ?> 211