Apache-lamp with PHP's zip library, but said not found =. =

Source: Internet
Author: User
Tags zip extension
I am a very water web application ape, basically did not write any project. A look at the problem is also very water, but in the internet for a long time, also did not find the answer, I hope the heroes do not spray me.

The environment is as follows:

    • ArchLinux 3.16.3
    • Apache 2.4.10
    • PHP 5.6.0

The requirement is to select from the page, download the zip file from other places to the server, then unzip the output to the client. In the writing process, there is a doubt that the fwrite files written to/tmp/xx.zip are not visible to the ordinary users on the server. Simply use

exec('ls /tmp/*.zip', $result);print_r($result);

Can be displayed, and by file_get_contents way of means to ensure that the file does exist.

The problem now is that the zip extension has been enabled in php.ini and it is also possible to execute the following code locally:

$zip = zip_open($target);if($zip) {    while($entry = zip_read($zip)) {        echo zip_entry_name($entry) . ': ' .            zip_entry_filesize($entry) . '/' .            zip_entry_compressedsize($entry) . ', by' .            zip_entry_compressionmethod($entry) . "\n";    }    zip_close($zip);}

Note that local execution, that is php file.php , but placed in the Apache directory, is not accessible through the browser. Error message:PHP Fatal error: Call to undefined function zip_open()

Reply content:

I am a very water web application ape, basically did not write any project. A look at the problem is also very water, but in the internet for a long time, also did not find the answer, I hope the heroes do not spray me.

The environment is as follows:

    • ArchLinux 3.16.3
    • Apache 2.4.10
    • PHP 5.6.0

The requirement is to select from the page, download the zip file from other places to the server, then unzip the output to the client. In the writing process, there is a doubt that the fwrite files written to/tmp/xx.zip are not visible to the ordinary users on the server. Simply use

exec('ls /tmp/*.zip', $result);print_r($result);

Can be displayed, and by file_get_contents way of means to ensure that the file does exist.

The problem now is that the zip extension has been enabled in php.ini and it is also possible to execute the following code locally:

$zip = zip_open($target);if($zip) {    while($entry = zip_read($zip)) {        echo zip_entry_name($entry) . ': ' .            zip_entry_filesize($entry) . '/' .            zip_entry_compressedsize($entry) . ', by' .            zip_entry_compressionmethod($entry) . "\n";    }    zip_close($zip);}

Note that local execution, that is php file.php , but placed in the Apache directory, is not accessible through the browser. Error message:PHP Fatal error: Call to undefined function zip_open()

Local execution no problem, with URL Access said the function does not exist, the CLI environment and Apache is not a PHP.

Find the PHP location of the CLI environment to see if it is consistent with the mod_php location, if it is consistent, please:

Restart Apache.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.