What we can do is mirror the official php.net website on our local system. The instructions are there on PHP site on how to set up official mirrors. But these official mirrors have everything, Downloads, etc. Basically a whole copy of php.net, content that we do not need. We only need manuals. So we can set up the unofficial mirror on our local web server.
The instructions to create an official mirror for php.net are here -> http://php.net/mirroring.php
I have modified the rsync command to meet the my requirement of downloading only the english manuals, and exclude as many things as possible. Create a shell script for it. This shell script can be used in cron to schedule a refresh with main site.
Change the variables at the start of the script to suit your system. Get the correct RRN for you from PHP.net rsync distribution plan and set YOUR_RRN_HOSTNAME correctly.
localPath should be set to where you want to keep the mirror. This should also be your web directory.
In the rsync command ‘manual/en‘ is for downloading English manuals. Change this to suit your language preference.
You can see at line 17, I have a sed command. This comments out the contents of .htaccess after downloading it from PHP site. The reason is that commands in it Order allow, deny are not compatible with Apache version I have on my system. I will update the post when I work on the alternative.
Now that we have got all the files required for mirroring PHP site, time to create Apache VirtualHost for this mirror. You can get the VirtualHost file provided by php.net from the instructions about mirroring the site, link is above in this post.
I am using openSuSE and in it all custom VirtualHost files are kept at /etc/apache2/vhosts.d. Check this for your system.
Here is my VirtualHost file.
# Do not display directory listings if index is not present,
# and do not try to match filenames if extension is omitted
Options -Indexes -MultiViews
#ServerAlias cc.php.net www.php.net the.cname.you.set.up.example.com
# Webroot of PHP mirror site
# Log server activity
# 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)
# A few recommended PHP directives
php_flag display_errors off
The changes I did to make mirror work on my system are
Line 02: Put in actual path where php.net site have been downloaded to. This will be localPath in the script above.
Line 08: Local URL of the site.
Line 09: We are not creating official PHP mirror site, so comment this out.
Line 10: Give your server admin email.
Line 14: Again put in actual path where php.net site have been downloaded to. This will be localPath in the script above.
Line 17-18: I have commented logging as it is already configured for my Apache server. If you wish to, change the path where you want logs to be maintained.
Everything done, the mirror should be working now.
Note: The URL of the manuals will be your SITE_URL/manual/en. SITE_URL local server address to location where you have downloaded the files
Here is a snapshot from my system