我的EC2服务器设置了Ubuntu 16,安装了LAMP& Symfony3。
服务器在线,因此没有问题。
我已将我的Symfony文件上传到/ var / www / html / project并成功设置了我的parameter.yml文件,设置了数据库,并完成了所有安装要求。我已经完成了composer.phar install,doctrine:schema:update等等 - 这一切都有效。
我已将000-default.conf更改为以下内容并重新启动了apache。
<VirtualHost *:80>
ServerName site.com
ServerAlias dev.site.com
ServerAdmin admin@site.com
DocumentRoot /var/www/html/project/web
DirectoryIndex app.php
<Directory /var/www/html/project/web >
DirectoryIndex app.php
AllowOverride All
Allow from All
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
现在,当我去查看我的网站时,我得到了
此页面无效
dev.site.com目前无法处理此请求。 HTTP错误 500
因此,为了测试并查看000-default.conf配置是否设置为正确路由到我的Symfony安装,我编辑了我的web / app.php文件并放置了echo 1;死;在标题处。然后,我可以在页面上显示“1”,因此我知道服务器正在运行,默认站点正在运行并将所有请求路由到正确的位置。
当我查看我的error.log时,我得到以下内容,我不知道该怎么做或如何解决此错误:
未捕获的TypeError:返回值 学说\ COMMON \注解\ AnnotationRegistry :: registerLoader() 必须是Doctrine \ Common \ Annotations \ void,none的实例 回来了 /var/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117\nStack 跟踪:\ n#0 /var/www/html/rekonnect/app/autoload.php(9): 学说\ COMMON \注解\ AnnotationRegistry :: registerLoader(阵列)\ n#1 /var/www/html/project/web/app.php(6): require('/ var / www / html / p ...')\ n#2 {main} \ n抛出 /var/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php 在第117行
我查看了var / logs / prod.log,并且在那里找不到任何说明为什么我的项目会抛出500错误。
我不知道接下来要做什么让我的Symfony项目显示在浏览器中。有什么帮助吗?
答案 0 :(得分:4)
您的服务器上可能安装了PHP版本&lt; 7.1。更新您的PHP版本以解决此问题。
PHP 7.1中添加了void
返回类型。 (见answer)。 Doctrine使用void
返回类型,但PHP似乎在Doctrine命名空间中查找无法找到它的类型。
[..]必须是Doctrine \ Common \ Annotations \ void
的实例
答案 1 :(得分:1)
Uncaught TypeError:Doctrine \ Common \ Annotations \ AnnotationRegistry :: registerLoader()的返回值必须是Doctrine \ Common \ Annotations \ void的实例,在/ var / www / html / project / vendor / doctrine /中返回none annotations / lib / Doctrine / Common / Annotations / AnnotationRegistry.php:117 \ n堆栈跟踪:\ n#0 /var/www/html/rekonnect/app/autoload.php(9):Doctrine \ Common \ Annotations \ AnnotationRegistry :: registerLoader(Array)\ n#1 /var/www/html/project/web/app.php(6):require(&#39; / var / www / html / p ...&#39;)\ n在第117行的/var/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php中抛出#2 {main} \ n
环顾四周似乎这个错误是由最新版本的Doctrine Annotation引起的,该版本使用了Php 7.1的功能。 (Doctrine2 Update Caused AnnotationRegistry registerLoader Error in Zend Framework 3)。
为了确保这一点,我建议使用Php Compat Info之类的工具运行最低要求的版本分析。将结果与服务器上安装的PHP版本进行比较。
如果您发现相对于所需的最低版本具有较低版本,则可以尝试升级PHP或更改composer中PHP版本的约束。例如,如果您已安装php 7.0,但所需的最低版本为7.1,请将此约束添加到您的composer文件中:
"require": {
"php": ">=7.0.0",
...
}