Php Symfony 3.0 Apache Http错误404和Http错误500响应
大家好,我尝试使用Symfony 3.0在Apache2上部署一个示例代码。我制作了一个示例控制器:Php Symfony 3.0 Apache Http错误404和Http错误500响应,php,symfony,amazon-ec2,apache2,Php,Symfony,Amazon Ec2,Apache2,大家好,我尝试使用Symfony 3.0在Apache2上部署一个示例代码。我制作了一个示例控制器: <?php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
/*Request Response*/
use Symfony\Component\HttpFoundation\Response;
/*End of: "Request Response"*/
class PagesController extends Controller
{
/**
*@Route("/test", name="index")
*/
public function test()
{
$response = new Response("Hello1");
return $response;
}
/**
*@Route("/test2", name="index2")
*/
public function test2()
{
$response = new Response("Hello2");
return $response;
}
}
Anv参观了工厂,工作正常
我的服务器上的Vhost配置为:
<VirtualHost *:80 >
ServerName ec2-52-48-111-226.eu-west-1.compute.amazonaws.com
DocumentRoot /home/www/syphotest/htdocs/web
DirectoryIndex app.php
ErrorLog /home/www/syphotest/logs/error.log
CustomLog /home/www/syphotest/logs/access.log combined
<Directory /home/www/syphotest/htdocs/web>
Require all granted
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
SetEnv OPENSHIFT_POSTGRESQL_DB_HOST localhost
SetEnv OPENSHIFT_POSTGRESQL_DB_PORT 5432
SetEnv OPENSHIFT_APP_NAME sampledb
SetEnv OPENSHIFT_POSTGRESQL_DB_USERNAME sampleuser
SetEnv OPENSHIFT_POSTGRESQL_DB_PASSWORD samplepass
</VirtualHost>
同样,从缓存中删除dev文件夹也没有解决问题
最后,当我调试我的路由时,我得到:
sudo php bin/console debug:route
-------------------------- -------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------------------------
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
index ANY ANY ANY /test
index2 ANY ANY ANY /test2
user_login POST ANY ANY /user/login
user_register POST ANY ANY /user/register
user_activate POST ANY ANY /user/activate
-------------------------- -------- -------- ------ -----------------------------------
您应该将app.php环境更改为生产环境 php位于{root_dir}/web下/ 找到线路
$kernel=newappkernel('prod',false)代码>
并将其替换为
$kernel=newappkernel('prod',true)代码>
[2016-02-16 17:08:44] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /test2"" at /home/www/syphotest/htdocs/var/cache/prod/classes.php line 2386 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /test2\" at /home/www/syphotest/htdocs/var/cache/prod/classes.php:2386, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): at /home/www/syphotest/htdocs/var/cache/prod/appProdUrlMatcher.php:71)"} []
sudo php bin/console debug:route
-------------------------- -------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------------------------
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
index ANY ANY ANY /test
index2 ANY ANY ANY /test2
user_login POST ANY ANY /user/login
user_register POST ANY ANY /user/register
user_activate POST ANY ANY /user/activate
-------------------------- -------- -------- ------ -----------------------------------