app.php在Symfony 3上显示为纯文本

时间:2017-07-06 05:51:48

标签: php apache symfony symfony-3.1

将我的应用程序设置为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.

我尝试了很多可能的配置,但是我无法理解,不知道发生了什么?

1 个答案:

答案 0 :(得分:2)

安装php并为其Web服务器启用其扩展