MEWBIES@: Facebook Twitter G+ YouTube DeviantArt Forum Wall
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ██
█▌ - ENABLE THE VIEWING & EXTRACTION OF RAR FILES - █▌
█▌ ON YOUR WEB SERVER - NIX, WIN XAMPP █▌
█ ▐▌
█ To support the viewing and extracting of rar files through php scripts you ▐▌
█ need to install PECL's rar module; "This extension gives you possibility ▐▌
█ to read Rar archives but doesn't support writing Rar archives, because ▐▌
█ this is not supported by the UnRar library and is directly prohibited by ▐▌
█ its license." ▐▌
█ ▐▌
█ Below is showing rar enabled using phpinfo() page: ▐▌
█ ▐▌
█ If it isn't installed and a user tries to extract or view a rar file there ▐▌
█ will be an error similar to: ▐▌
█ extract_failure - RAR Extraction not supported by your PHP installation. ▐▌
█ * The RAR compression method requires the RAR PECL module ▐▌
█ */ ▐▌
█ class extArchiveRar { ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ WINDOWS - XAMPP ▐▌
█ LINUX ▐▌
█ TROUBLE SHOOTING PECL'S RAR (and manual compile/install Linux) ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ WINDOWS XAMPP INSTALL: ▐▌
█ `````````````````````` ▐▌
█ PREREQUISTIES: ▐▌
█ PHP 5.3 or 5.4 and a phpinfo() page, view here. ▐▌
█ ▐▌
█ INSTALL: ▐▌
█ 1. Download from here the extension for your version of PHP: ▐▌
█ If you have PHP 5.3 download v5.3, etc. ▐▌
█ 'ZTS' vs 'no ZTS' means 'ZEND Thread Safety'. View your php.ini if you use ▐▌
█ it: ▐▌
█ zend_extension_ts =... ▐▌
█ If not then download the 'no ZTS' version. ▐▌
█ ▐▌
█ 2. Extract the file, copy the 'php_rar.dll' to your extension directory: ▐▌
█ \xampp\php\ext\ ▐▌
█ You don't need 'php_rar.pdb' unless you want to compile the .dll yourself. ▐▌
█ ▐▌
█ 3. Edit your php.ini, \xampp\php\php.ini, add the extension with the ▐▌
█ others under '; Windows Extensions': ▐▌
█ extension=php_rar.dll ▐▌
█ Check that on your php.ini is also the correct path to pear. For example ▐▌
█ mine has: ▐▌
█ ; Windows: "\path1;\path2" ▐▌
█ include_path = ".;D:\xampp\php\pear\" ▐▌
█ ▐▌
█ 4. Restart your server, then view your phpinfo() page if rar is enabled ▐▌
█ like in the images. ▐▌
█ If the extension doesn't show then check your logs to trouble shoot why. ▐▌
█ ▐▌
█ If it still cannot work, it could be that the .dll was compiled with a ▐▌
█ version that isn't compatible for your PHP. You can try then downloading ▐▌
█ the extension from here - I'm not sure if it is compiled with VC6 or 9 but ▐▌
█ might be worth a try (the above is VC9). ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ LINUX INSTALL: ▐▌
█ `````````````` ▐▌
█ PREREQUISITES: ▐▌
█ gcc, phpize, php-pear, php5-dev ▐▌
█ To view if you have installed: ▐▌
█ which phpize && which gcc ▐▌
█ Output if you do will list the location of each, my output: ▐▌
█ /usr/bin/phpize ▐▌
█ /usr/bin/gcc ▐▌
█ And: ▐▌
█ dpkg -l php-pear php5-dev ▐▌
█ Output if you have those installed will be similar to: ▐▌
█ ii php-pear 5.3.3-7+squeeze15 PEAR - PHP Extension and Application ▐▌
█ ii php5-dev 5.3.3-7+squeeze15 Files for PHP5 module development ▐▌
█ ▐▌
█ Install those that you don't have via package manager: ▐▌
█ su ▐▌
█ aptitude install gcc php-pear php5-dev (phpize is installed w php5-dev) ▐▌
█ ▐▌
█ Also we are going use phpinfo() to view the status of the rar module; view ▐▌
█ here. ▐▌
█ ▐▌
█ INSTALL PECL MODULE RAR: ▐▌
█ Once all prerequisites are done, it is silly simple via pecl: ▐▌
█ pecl -v install rar ▐▌
█ View last note here if installing on OpenSUSE. ▐▌
█ (If you want to manually compile and install it, directions are under ▐▌
█ TROUBLE SHOOTING below.) ▐▌
█ Output will be a bit long. ▐▌
█ ▐▌
█ If the install exited with an error - view the error, if it is because ▐▌
█ 'command not found', then install it, for example this would mean phpize ▐▌
█ is missing: ▐▌
█ running: phpize sh: phpize: command not found ▐▌
█ ▐▌
█ Now we need to add the rar extenstion to php.ini: ▐▌
█ pico /etc/php5/apache2/php.ini ▐▌
█ Add towards the top of the file AFTER [PHP], ioncube and zend (if you have ▐▌
█ those installed): ▐▌
█ extension=rar.so ▐▌
█ ▐▌
█ Here is the top part of my php.ini: ▐▌
█ [PHP] ▐▌
█ zend_extension=/usr/local/lib/ioncube/ioncube_loader_lin_5.3.so ▐▌
█ zend_extension=/usr/local/lib/Zend/ZendGuardLoader.so ▐▌
█ zend_optimizer.optimization_level=15 ▐▌
█ zend_loader.enable=1 ▐▌
█ zend_loader.disable_licensing=0 ▐▌
█ zend_loader.obfuscation_level_support=3 ▐▌
█ ;extension=php_curl.dll ▐▌
█ ;extension=curl.so ▐▌
█ extension=rar.so ▐▌
█ ▐▌
█ Restart Apache sever: ▐▌
█ /etc/init.d/apache2 restart ▐▌
█ Open your phpinfo() in a browser to view if rar is enabled, like in the ▐▌
█ images above. ▐▌
█ ▐▌
█ ___________..___________ ▐▌
█ ▐▌
█ TROUBLE SHOOTING PECL'S RAR (and manual compile/install Linux): ▐▌
█ ``````````````````````````````````````````````````````````````` ▐▌
█ If after doing an upgrade to PHP and you receive errors similar to: ▐▌
█ PHP Warning: PHP Startup: rar: Unable to initialize module ▐▌
█ Module compiled with module API=20060613 ▐▌
█ PHP compiled with module API=20090626 ▐▌
█ Cron <root@yourdomain> [ -x /usr/lib/php5/maxlifetime ] && ▐▌
█ [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin ▐▌
█ +$(/usr/lib/php5/maxlifetime) -delete ▐▌
█ PHP Warning: PHP Startup: Unable to load dynamic library ▐▌
█ '/usr/lib/php5/20090626+lfs/rar.so' - /usr/lib/php5/20090626+lfs/rar.so: ▐▌
█ cannot open shared object file: No such file or directory in Unknown on ▐▌
█ line 0 ▐▌
█ ▐▌
█ It will also be in your logs: tail -50 /var/log/apache2/error.log ▐▌
█ '/usr/lib/php5/20100525+lfs/rar.so' - /usr/lib/php5/20100525+lfs/rar.so: ▐▌
█ ▐▌
█ The last lines of this error are important as it states which file has ▐▌
█ the problem. ▐▌
█ In this case: /usr/lib/php5/20090626+lfs/rar.so ▐▌
█ ls /usr/lib/php5/20090626+lfs ▐▌
█ Sure enough no rar.so there. That is because the original version I ▐▌
█ installed is here: ▐▌
█ ls -Al /usr/lib/php5/20060613+lfs ▐▌
█ -rw-r--r-- 1 root root 1037732 Jun 30 2010 rar.so ▐▌
█ Now you just can't edit php.ini to look there, or copy over rar.so to the ▐▌
█ correct path because it is simply not a compatible version. ▐▌
█ ▐▌
█ A newer version of PHP requires a newer version of the 'rar.so' in this ▐▌
█ matter. ▐▌
█ You can fix this by doing like above: pecl -v install rar ▐▌
█ Or I like to do it manually; it's very easy: The manual is here, ▐▌
█ check their site for the latest version here, then download it: ▐▌
█ wget http://pecl.php.net/get/rar-3.0.2.tgz ▐▌
█ Note only: If the URL isn't a full file name, state file name you want ▐▌
█ to save file as with option -O, for example v3.0.1 didn't have ▐▌
█ a full URL when first posted: ▐▌
█ wget http://pecl.php.net/get/rar -O rar-3.0.1.tgz ▐▌
█ tar xvzf rar-3.0.2.tgz && cd rar-3.0.2 ▐▌
█ phpize ▐▌
█ Output will be similar to: ▐▌
█ Configuring for: ▐▌
█ PHP Api Version: 20100412 ▐▌
█ Zend Module Api No: 20100525 ▐▌
█ Zend Extension Api No: 220100525 ▐▌
█ ▐▌
█ Then: ▐▌
█ ./configure && make ▐▌
█ Test it: ▐▌
█ make test ▐▌
█ Output: ▐▌
█ [snip] ▐▌
█ Tests passed : 96 ( 97.0%) (100.0%) ▐▌
█ [snip] ▐▌
█ Do you want to send this report now? [Yns]: ▐▌
█ ▐▌
█ Now to install it: ▐▌
█ su ▐▌
█ make install ▐▌
█ Output: Installing shared extensions: /usr/lib/php5/20100525+lfs/ ▐▌
█ ▐▌
█ Add the extension to your php.ini if you haven't before already: ▐▌
█ pico /etc/php5/apache2/php.ini ▐▌
█ Add this line after [PHP] (after ioncube and zend IF you have those ▐▌
█ installed): ▐▌
█ extension=rar.so ▐▌
█ ▐▌
█ Restart your Apache server: ▐▌
█ /etc/init.d/apache2 restart ▐▌
█ ▐▌
█ Open your phpinfo() in a browser to view if rar is enabled like the above ▐▌
█ images. ▐▌
█ Done. ▐▌
█ ▐▌
█ exit ▐▌
█ Clean up: ▐▌
█ cd .. ▐▌
█ rm rar-3.0.2 -rf ▐▌
█ ▐▌
█ Tip: To view all extensions PHP is listed to load: ▐▌
█ grep -Hrv ";" /etc/php5 | grep -i "extension=" ▐▌
█ ▐▌
█ //---------------------------------------------------------------------- ▐▌
█ ▐▌
█ If you find mistakes, have suggestions, and or questions please post at ▐▌
█ mewbies forum HERE - thank you. ▐▌
█ ▐▌
█ Last update on 18 Nov '13 ▐▌
█ ▐▌
█▌ █▌
█▌ - mewbies.com - █▌
█▌ █▌
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██