简体   繁体   English

phar文件未在apache下运行

[英]phar file not running under apache

I am trying to run a simple phar file from a web browser with apache. 我正在尝试使用apache从网络浏览器运行一个简单的phar文件。 I got this from the PHP manual 我是从PHP手册中得到的

<?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 如果浏览到/myphar.phar/index.php,则显示Hello World

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. 如果我导航到/myphar.phar,我仍然找不到,但是phar文件已下载。

How do I set things up so that phar file will work as expected? 我该如何设置以使phar文件能够按预期工作?

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 我需要将以下内容添加到httpd.conf中

AddType application/x-httpd-php .php .phar AddType应用程序/ x-httpd-php .php .phar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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