I'm trying to install the rar package. I checked php.net's installation docs and it just said to execute pecl -v install rar
I did it and rebooted server but its still not working. I'm not very familiar with the Linux stuff so maybe did I do something wrong?
Phpinfo also display nothing about RAR package.
I'm trying to execute this script, I found it on php.net docs so it should be working:
$rar_arch = RarArchive::open('dl/test.rar');
if ($rar_arch === FALSE)
die("Could not open RAR archive.");
$rar_entries = $rar_arch->getEntries();
if ($rar_entries === FALSE)
die("Could retrieve entries.");
echo "Found " . count($rar_entries) . " entries.\n";
foreach ($rar_entries as $e) {
echo $e;
echo "\n";
}
$rar_arch->close();
Answering this 4 year old question just because I had the same problem and I'm fairly new to the PHP/Apache/Pecl stack:
Basically, I followed this guide. However, I have 2 versions of PHP installed and had to make some tweaks to make it work (also, update instructions to how PHP versions work as of 2018):
sudo apt-get install php5.6-dev
pecl -v install rar
RAR extension was installed on /usr/lib/php/20131226
Checked where were my extensions directory:
php -i | grep extension
extension_dir => /usr/lib/php/20160303 => /usr/lib/php/20160303
Added a line on /etc/php/5.6/apache2/php.ini
extension=/usr/lib/php/20131226/rar.so
Then, restarted apache server as usual and everything worked fine!
sudo service apache2 restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With