Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 虚拟主机赢得';t运行Symfony2_Php_Apache_Symfony - Fatal编程技术网

Php 虚拟主机赢得';t运行Symfony2

Php 虚拟主机赢得';t运行Symfony2,php,apache,symfony,Php,Apache,Symfony,我已经安装了Apache2,我在虚拟主机上安装了这个程序,指向我的symfony项目 <VirtualHost *:80> ServerName topbesterp ServerAlias www.topbesterp.tld DocumentRoot /var/www/topbesterp/web/ <Directory /var/www/topbesterp/web/> AllowOverride All

我已经安装了
Apache2
,我在虚拟主机上安装了这个程序,指向我的symfony项目

<VirtualHost *:80>

    ServerName topbesterp
    ServerAlias www.topbesterp.tld

    DocumentRoot /var/www/topbesterp/web/

    <Directory /var/www/topbesterp/web/>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    <Directory /var/www/topbesterp/web/>
         Options FollowSymlinks
    </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined

</VirtualHost>
每当我运行
http://topbesterp
在我的浏览器上,我收到一个空白页。
但是,每当我将虚拟主机的目录更改为非基于symfony的项目时,它都可以正常运行。为什么?

替换
/var/www/topbesterp/web/

为了


事实上,您没有在虚拟主机中指定目录索引,请尝试此操作以获取symfony2第一页(
app_dev.php
用于开发/
app.php
用于生产):


服务器名topbesterp
ServerAlias www.topbesterp.tld
DocumentRoot/var/www/topbesterp/web
DirectoryIndex应用程序_dev.php
允许超越所有
命令允许,拒绝
通融
选项如下符号链接
ErrorLog/var/log/apache2/project\u error.log
CustomLog/var/log/apache2/project\u access.log组合

假设您在灯环境中,请按照以下步骤操作。如果是的话

1.

sudo nano /etc/apache2/sites-available/topbesterp.local.conf


<VirtualHost *:80>
    ServerName topbesterp.local
    ServerAlias www.topbesterp.local
    ServerAdmin admin@topbesterp.local

    DocumentRoot /var/www/topbesterp/web

    <Directory /var/www/topbesterp/web/>
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/topbesterp.local.error.log
    CustomLog ${APACHE_LOG_DIR}/topbesterp.local.access.log combined
</VirtualHost>
sudo a2ensite topbesterp.local.conf
sudo service apache2 restart
sudo nano /etc/hosts

127.0.0.1       topbesterp.local www.topbesterp.local
3.

sudo nano /etc/apache2/sites-available/topbesterp.local.conf


<VirtualHost *:80>
    ServerName topbesterp.local
    ServerAlias www.topbesterp.local
    ServerAdmin admin@topbesterp.local

    DocumentRoot /var/www/topbesterp/web

    <Directory /var/www/topbesterp/web/>
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/topbesterp.local.error.log
    CustomLog ${APACHE_LOG_DIR}/topbesterp.local.access.log combined
</VirtualHost>
sudo a2ensite topbesterp.local.conf
sudo service apache2 restart
sudo nano /etc/hosts

127.0.0.1       topbesterp.local www.topbesterp.local

根据我的评论,您需要检查
app/logs/dev.log
app/logs/prod.log
,具体取决于您运行应用程序的环境

如果在cache/logs文件夹中看到一些写入错误,则需要设置对
app/cache/*
app/logs/*
文件夹的正确权限

  • app/console
  • web/app\u dev.php
  • web/app.php

你已经添加了
DirectoryIndex/var/www/topbesterp/web/app.php
?还有,日志告诉你什么?我忘了检查日志。目录上的一切都很好。然后在我检查了日志之后,我发现symfony的cahche和logs文件夹没有权限。我同意了,现在一切都好了。谢谢执行此操作时显示的内容:
http://topbesterp/app_dev.php
sudo nano /etc/hosts

127.0.0.1       topbesterp.local www.topbesterp.local