This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

404 on prod environement, many fixes online, none working

Discuss installing Symfony 2 here

404 on prod environement, many fixes online, none working

by PyWebDesign » Tue Sep 24, 2013 5:55 pm

I'm new to symfony, I am comming from the Laravel community and want to try something fresh and with a bigger community. I speaks french btw.

I was following the book about symfony, and I find it very difficult to follow right now. I had to figure out a lot of stuff wich aren't noob freindly and my solutions may not be very good.

so here goes the story of what I did (everything that is questionnable is in bold so it's easier to read!:

Code: Select all
$composer create-project symfony/framework-standard-edition symfony 2.3.0

return an error :
touch(): Utime failed: Permission denied
don't know why!

Code: Select all
$ sudo composer create-project symfony/framework-standard-edition symfony 2.3.0

this installed symfony

Code: Select all
$ sudo chown {user}:{user} -R symfony

this make me able to modify files in the symfony install directory. Don't know why it's locked up after the installation!

I then check
404 error

I get the common app/cache and app/logs errors

Code: Select all
$ sudo chown www-data:www-data symfony/app/cache/
$ sudo chown www-data:www-data symfony/app/logs/
$sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX symfony/app/cache symfony/app/logs

this should be good right?

If I go to
I get a 404 but,
works, now!

I didn't follow the git part for now, wanting to try symfony soon!

Following the tutorial about the greeting page:
Code: Select all
$php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml

I am now asked many questions about the installation. I don't know what to answer (it's not in the book!)

I keep default setting for everythings! Still nice, I thinks, but discouraging a little bit!

I change the file src/Acme/HelloBundle/Resources/config/routing.yml with:

Code: Select all
# src/Acme/HelloBundle/Resources/config/routing.yml
    pattern:  /hello/{name}
    defaults: { _controller: AcmeHelloBundle:Hello:index }

src/Acme/HelloBundle/Controller/HelloController.php with:
Code: Select all
// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

class HelloController
    public function indexAction($name)
        return new Response('<html><body>Hello '.$name.'!</body></html>');

And I browse to

and bam! it work!

but still return an 404 error.

why? what should I do? I would really like to understant prod environement

then: google!
I tried to clear cache,
change a line in app kernel, from false to true about the prod environnement and still nothing. The error message changes a little bit, it's worst!

Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to write cache file "/home/dog/Dropbox/www/localhost/symfony/app/cache/prod/classes.php".' in /home/dog/Dropbox/www/localhost/symfony/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php:239 Stack trace: #0 /home/dog/Dropbox/www/localhost/symfony/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php(122): Symfony\Component\ClassLoader\ClassCollectionLoader::writeCacheFile('/home/dog/Dropb...', '<?php ?namespac...') #1 /home/dog/Dropbox/www/localhost/symfony/app/bootstrap.php.cache(2348): Symfony\Component\ClassLoader\ClassCollectionLoader::load(Array, '/home/dog/Dropb...', 'classes', true, false, '.php') #2 /home/dog/Dropbox/www/localhost/symfony/app/bootstrap.php.cache(2184): Symfony\Component\HttpKernel\Kernel->doLoadClassCache('classes', '.php') #3 /home/dog/Dropbox/www/localhost/symfony/app/bootstrap.php.cache(2218): Symfony\Component\HttpKernel\Kernel->boot() #4 /home/dog/Dropbox/www/loca in /home/dog/Dropbox/www/localhost/symfony/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php on line 239

sadly I don,t know what to do from there
Junior Member
Posts: 1
Joined: Tue Sep 24, 2013 5:01 pm

Re: 404 on prod environement, many fixes online, none workin

by tiagojsag » Wed Sep 25, 2013 5:58 pm


Welcome to Symfony. Let's help you get started.

touch(): Utime failed: Permission denied

I guess you're trying to install Symfony2 in a dir where you have no write permissions. At this point, you should have checked and changed your permissions. Instead, you decided to use brute force and install Symfony with sudo. That means your symfony files belong to the 'root' user, so all your other permissions problems are because of this. Don't blame it on the Symfony book. You added the "sudo" call yourself, so it's not the book that's wrong, it's you that sidetracked from it ;)

This is not a bug, it's a security feature. By default, Symfony comes with two environments: dev (used by app_dev.php) and prod (used by app.php). The welcome stuff is part of the AcmeHelloBundle, and is only available on the dev environment, under app_dev.php. You wouldn't want to accidentally make it available on your production server, would you? Take a careful look at app/AppKernel.php to see how symfony knows which bundles to use in each situation.

Next, the bundle generation: those come with defaults, which you can use until you understand what each option does. Like in all tutorials, unless you're told otherwise, use the defaults ;)

Finally, your last error is, again, permissions.

Tiago Garcia

Core Web Developer @ Shopware
User avatar
Faithful Member
Posts: 885
Joined: Wed Aug 10, 2011 4:58 pm