【问题标题】:Symfony 2 Apache 2.4 php7 ugrade Vhost fileSymfony 2 Apache 2.4 php7 升级 Vhost 文件
【发布时间】:2018-01-18 14:07:35
【问题描述】:

我的服务器被黑了我别无选择,只能创建一个新服务器,所以我现在升级到最新的 Apache 2.4 和 PHP 7 不幸的是我发现我的 Symofony 2 应用程序无法运行我在使用 Vhost 时遇到问题配置。

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

这是原始虚拟主机。

<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>

【问题讨论】:

    标签: symfony virtualhost php-7 apache2.4


    【解决方案1】:

    我推荐了这个配置

    <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/ 阅读文档并生成您的配置

    【讨论】:

      【解决方案2】:

      命令允许,拒绝

      这已经不存在了。

         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

      【讨论】:

        猜你喜欢
        • 2016-03-25
        • 2016-09-22
        • 2014-06-16
        • 2016-02-05
        • 2015-10-25
        • 2018-07-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多