2017-08-10 76 views
1

我的服务器被黑了我没有别的办法,除了创建一个新的服务器这样做我现在不幸升级到最新的Apache 2.4和PHP 7我发现我的Symofony 2应用程序没有工作我遇到了Vhost配置问题。Symfony 2 Apache 2.4 php7 ugrade Vhost文件

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

这是原始的虚拟主机。

<VirtualHost *:80> 

    ServerAdmin [email protected] 
    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> 

回答

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/

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