-
Notifications
You must be signed in to change notification settings - Fork 542
/
mirroring.php
210 lines (172 loc) · 6.89 KB
/
mirroring.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
$_SERVER['BASE_PAGE'] = 'mirroring.php';
include_once __DIR__ . '/include/prepend.inc';
$SIDEBAR_DATA = '
<h3>Existing mirror sites</h3>
<p>
Properly working mirror sites are listed on <a href="/mirrors.php">our
mirrors page</a>.
</p>
';
site_header(
'Mirroring The PHP Website',
[
'current' => 'community',
'layout_span' => 12,
],
);
?>
<h1>Mirroring The PHP Website</h1>
<p>
The PHP project does not have an official mirror program anymore, but you can
set up a mirror for your own network or company.
</p>
<p>
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, <a href="#exclude">exclude the manual in all languages that you
will not be using and exclude the distributions directory</a>.)
</p>
<h2>Get Files With Rsync</h2>
<p>
First, you need to have a <a href="http://rsync.samba.org/">rsync</a>
installed.
To synchronize your server with the appropriate rsync location, first view the <a
href="/images/oidk.net-rsync-distribution-plan-may2012.png">coverage map</a>
and identify which location your mirror should be using. Next, modify the
following code for use with your mirror. Replace <code>YOUR_RRN_HOSTNAME</code>
with your RRN's hostname as indicated by the coverage map and be sure to
change <code>/your/local/path</code> with the path to where your php.net
mirror will reside on the filesystem.
</p>
<pre class="info">
rsync -avzC --timeout=600 --delete --delete-after \
--include='distributions/*.exe' \
YOUR_RRN_HOSTNAME::phpweb /your/local/path
</pre>
<a name="exclude"></a>
<p>
If you only want to mirror mirror one language of the manual? Add:
</p>
<pre class="info">
--include='manual/en/' --include='manual/en/**' --exclude='manual/**' --exclude='distributions/manual/**'
</pre>
<p>
after <code>"--delete-after"</code> in the command line above (substituting your
prefered language code in place of <code>'en'</code>). You can also exclude the
whole distributions directory (and the related extra folder) by replacing
<code>"--exclude='distributions/manual/**'"</code> with
<code>"--exclude='distributions/**' --exclude='extra/**'"</code>.
</p>
<h2>Add SQLite 3 Support</h2>
<p>
<a href="http://www.sqlite.org">SQLite</a> 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.
</p>
<p>
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.
</p>
<h2>Setup Apache VirtualHost</h2>
<p>
Make sure your web server is set up to serve <code>.php</code> files as PHP
parsed files. If it isn't, add the MIME type to your config.
</p>
<p class="warn">
Please make sure you have turned off output compression for binary files.
</p>
<p>
Create a VirtualHost entry, which looks something like:
</p>
<a name="settings"></a>
<pre class="info">
<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
</Directory>
ServerName mymirror.example.com
ServerAdmin [email protected]
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"
# 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
</IfModule>
# 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
</VirtualHost>
</pre>
<p>
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
<a href="http://httpd.apache.org/docs/vhosts/index.html">the Apache
documentation</a> for the differences of the two methods.
</p>
<p>
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.
</p>
<h2>Setup Regular Updates</h2>
<p>
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:
</p>
<pre class="info">
5 * * * * rsync -avzC --timeout=600 --delete --delete-after --include='distributions/*.exe' YOUR_RRN_HOSTNAME::phpweb /your/local/path
</pre>
<p>
Remember to specify the same rsync parameters you used to get the
<code>phpweb</code> 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.
</p>
<h2>Mirror Setup Troubleshooting</h2>
<p>
The <a href="/mirroring-troubles.php">mirror troubleshooting guide</a>
contains information about the common and potential problems discovered
when setting up and maintaining a mirror of PHP.net. Included are links that
can help demonstrate common configuration problems.
</p>
<?php site_footer(); ?>