Symfony 2 Apache 2.4 php7 ugrade Vhost文件

时间:2017-08-10 10:55:38

标签: symfony virtualhost php-7 apache2.4

我的服务器遭到黑客攻击除了创建一个新的服务器之外别无其他选择我升级到最新的Apache 2.4和PHP 7现在很遗憾我发现我的Symofony 2应用程序不起作用我遇到了Vhost的问题配置。

我真的很感激,如果有人可以帮助更新vhost文件,并指定是否有任何我需要安装的php mods来替换原始vhost文件中的旧php 5 mod。

这是原始的虚拟主机。

<VirtualHost *:80>

    ServerAdmin contact@example.net
    ServerName apps.example.com    ServerAlias www.apps.example.com    
    DocumentRoot /home/example.com.v2.0/Symfony2/web/
    DirectoryIndex app.php

    ErrorLog /var/log/apache2/example-apps-live-error_log
    CustomLog /var/log/apache2/example-apps-live-access_log combined

    HostnameLookups Off

    UseCanonicalName Off

    ServerSignature On

    <Directory "/home/example.com.v2.0/Symfony2/web/">
        #Require all granted
        Options -Indexes +FollowSymLinks -MultiViews -Includes +ExecCGI
            AllowOverride All
            AddHandler fcgid-script .php
            FCGIWrapper /home/php-fcgi-starter .php
        AcceptPathInfo On
            Order allow,deny
            allow from all    
    </Directory>

</VirtualHost>

2 个答案:

答案 0 :(得分:0)

我推荐了这个配置

<VirtualHost *:80>
ServerName      mi-sitio.com
ServerAlias     www.mi-sitio.com

SetEnv SYMFONY__DATABASE__USER     "..."
SetEnv SYMFONY__DATABASE__PASSWORD "..."

DocumentRoot    "/Proyectos/Symfony2/mi-sitio.com/web"
DirectoryIndex  app.php

<Directory "/Proyectos/Symfony2/mi-sitio.com/web">
    AllowOverride None
    Allow from All

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
</Directory>

CustomLog  /var/log/httpd/mi-sitio.com-access.log combined

KeepAlive            On
MaxKeepAliveRequests 200
KeepAliveTimeout     5

<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/rss+xml" \
                                  "application/x-javascript" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "image/svg+xml" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/xml"
</IfModule>

<IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary

    ExpiresActive On
    ExpiresDefault "now plus 1 week"
    ExpiresByType image/x-icon "now plus 1 month"
    ExpiresByType image/gif    "now plus 1 month"
    ExpiresByType image/png    "now plus 1 month"
    ExpiresByType image/jpeg   "now plus 1 month"
</IfModule>

您可以阅读文档并在http://symfony.es/documentacion/como-configurar-bien-apache-para-las-aplicaciones-symfony2/

生成配置

答案 1 :(得分:0)

订单允许,拒绝

这已经不存在了。

   Using mod_php/PHP-CGI with Apache 2.4¶

 In Apache 2.4, Order Allow,Deny has been replaced by Require all
 granted. Hence, you need to modify your Directory permission settings
 as follows: 

 <Directory /var/www/project/public>
     Require all granted
     # ... </Directory>

查看symfony的官方文档:https://symfony.com/doc/current/setup/web_server_configuration.html