Tag Archives: PHP

Set up local mirror of php.net 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 php.net documentation even when I am not connected to the internet.

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. 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
Working PHP unofficial mirror

Working PHP unofficial mirror

PHP with Oracle

I am personally working on a Project, that has web UI having Apache server, PHP on server side and Oracle as database. For this I need to configure PHP so that it can talk to my Oracle database. The first error I got while querying the database using PHP was. For this, we need to first install php5-pear and then using pecl, we need to install OCI8. As I am using openSUSE 13.2 Then install OCI8 extension for PHP This will install and compile oci8 module. This command will ask for ORACLE HOME location. If everything goes fine, this will end like Add the line to your /etc/php/apache2/php.ini and /etc/php/cli/php.ini Then restart Apache server After this when I tried to access Oracle, I got the error “Call to undefined function oci_connect()” again! When I checked in /var/log/apache2/err_log, I found this: So even though the file libnnz11.so is present at $ORACLE_HOME/lib, I still get this error. To get over this error, we need two more steps. Create a file /etc/ld.so.conf.d/oracle.conf and add this line it: and run “ldconfig”. Restart your Apache server again, and this time things should work!