【问题标题】:app.php shown as plain text on Symfony 3app.php 在 Symfony 3 上显示为纯文本
【发布时间】:2017-07-06 05:51:47
【问题描述】:

将我的应用设置为 EC2 实例,我有以下虚拟主机:

<VirtualHost *:80>
   ServerName melomaniacs.com

   ## Vhost docroot
   DocumentRoot "/var/www/html/myProject/web"
   DirectoryIndex  app.php

   ## Directories, there should at least be a declaration for /var/www/html/myProject/web

<Directory "/var/www/html/myProject/web">
       Options Indexes FollowSymLinks MultiViews
         AllowOverride None
         Order allow,deny
        Allow from All
        Satisfy Any
        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

   ## Logging
   ErrorLog "/var/log/httpd/melomaniacs_error.log"
   ServerSignature Off
   CustomLog "/var/log/httpd/melomaniacs_access.log" combined

   ## Server aliases
   ServerAlias *.melomaniacs.com
   SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

   ## Custom fragment

 </VirtualHost>

但是当我尝试访问 app.php(当我访问 IP 时)时,我将其内容作为纯文本获取:

loadClassCache(); $kernel = new AppCache($kernel); // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter //Request::enableHttpMethodParameterOverride(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);

更新: 刚刚尝试在 httpd.conf 中添加以下行:

LoadModule php7_module modules/libphp7.so 但它说:

[warn] module php7_module is already loaded, skipping when restarting apache.

我尝试了许多可能的配置,但我无法得到它,知道发生了什么吗?

【问题讨论】:

    标签: php apache symfony symfony-3.1


    【解决方案1】:

    安装 php 并为您的网络服务器启用其扩展

    【讨论】:

    • 那么它可能没有为 apache 启用,因为您的 apache 没有通过 php 处理器提供页面
    • 我可以在哪里启用?
    • sudo apt-get install libapache2-mod-php7.0(如果你的系统支持apt-get),然后重启apache
    • 谢谢山姆。我用的是centos 6.5,所以sudo yum install libapache2-mod-php7.0,对吧?
    • @Albeis :- 对此问题进行了哪些修复以使其正常工作?
    猜你喜欢
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-25
    • 2014-09-18
    • 2012-01-31
    • 2013-05-19
    相关资源
    最近更新 更多