我目前正在尝试在托管的VPS上部署我的Symfony 4网站,我确实成功完成了所有设置,安装了Apache2,PHP 7.2,MySQL服务器和phpmyadmin。 然后,我开始相应地配置服务器以托管Symfony 4网站,在部署自己的应用程序之前,我尝试部署一个较小的应用程序,以便使我知道至少有一部分可以与无数据库无捆绑程序一起使用。 当我尝试访问我的网站没有任何反应时,在/ var / log / apache2中生成以下错误日志:
[Wed Jul 11 14:06:08.580654 2018] [core:error] [pid 13404] [client 37.97.69.85:52997] AH00124: Request exceeded the limit of 10 internal redirects due to probable
configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:06:41.901738 2018] [php7:error] [pid 13423] [client 37.97.69.85:44931] PHP Fatal error:
Uncaught Symfony\\Component\\Dotenv\\Exception\\PathException: Unable to read the "/var/www/releases/20180710151554/public/../.env" environment file.
in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php:54\nStack trace:\n#0 /var/www/releases/20180710151554/public/index.php(15):
Symfony\\Component\\Dotenv\\Dotenv->load('/var/www/releas...')\n#1 {main}\n thrown in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php on line 54
[Wed Jul 11 14:33:33.702774 2018] [core:error] [pid 13442] [client 37.97.69.85:53026] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:38:07.055940 2018] [core:error] [pid 13642] [client 37.97.69.85:54628] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:51:50.406171 2018] [php7:error] [pid 13793] [client 37.97.69.85:55651] PHP Fatal error: Uncaught RuntimeException:
APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file. in /var/www/demo/public/index.php:13\nStack trace:\n#0 {main}\n thrown in /var/www/demo/public/index.php on line 13
我认为这是由于网站配置文件在某个地方循环而引起的,我在网上看到过.htaccess和配置文件在循环的情况,但是在这里,由于删除了.htaccess文件,所以在任何地方都没有.htaccess文件。 他是我的网站配置:
<VirtualHost *:80>
ServerName vps562960.ovh.net
ServerAlias vps562960.ovh.net
DocumentRoot /var/www/releases/20180710151554/public
<Directory /var/www/releases/20180710151554>
AllowOverride None
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/crvfakeexample.com>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/releases/20180710151554/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/vps562960.ovh.net_error.log
CustomLog /var/log/apache2/vps562960.ovh.net_access.log combined
# optionally set the value of the environment variables used in the application
#SetEnv APP_ENV prod
#SetEnv APP_SECRET <app-secret-id>
#SetEnv DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"
</VirtualHost>
我开始对部署该网站失去希望。有人遇到过类似的案件吗?或者你们当中有人知道我在做什么吗?
谢谢。
答案 0 :(得分:0)
最可能的问题是Apache服务器未将环境变量设置为PHP全局数组$_SERVER
。但是symfony试图精确地在$_SERVER
数组中找到env变量。更新public/index.php
并用$_SERVER
替换所有$_ENV
或在Apache网站conf中取消注释SetEnv
指令。