Set up local mirror of manual

I am building websites and at times I want to remain disconnected from the internet, but still want to keep looking at PHP, Javascript, jQuery or Bootstrap documentation. So here is what I do to refer documentation even when I am not connected to the internet.

What we can do is mirror the official 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, 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 are here ->
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 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 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. The changes I did to make mirror work on my system are
  • Line 02: Put in actual path where 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 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
Working PHP unofficial mirror

Working PHP unofficial mirror

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.