简体   繁体   中英

phar file not running under apache

I am trying to run a simple phar file from a web browser with apache. I got this from the PHP manual

<?php
// creating the phar archive:
try {
    $phar = new Phar('myphar.phar');
    $phar['index.php'] = '<?php echo "Hello World"; ?>';
    $phar['index.phps'] = '<?php echo "Hello World"; ?>';
    $phar->setStub('<?php
Phar::webPhar();
__HALT_COMPILER(); ?>');
} catch (Exception $e) {
    // handle error here
}
?>

The manual says

display Hello World if one browses to /myphar.phar/index.php

However when I do this I get a Not Found

If I navigate to /myphar.phar I still get Not Found but the phar file is downloaded.

How do I set things up so that phar file will work as expected?

Here is how I am attempting to access

https://192.168.100.226/myphar.phar/

I needed to add the following to the httpd.conf

AddType application/x-httpd-php .php .phar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM