4

I've deployed my Symfony2 project to my development server and want to run the dev environment.

Everything is running fine if I use /app.php but if I try app_dev.php I get a 404 error:

The requested URL /app_dev.php was not found on this server.

Below is a copy of my .htaccess file:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Explicitly disable rewriting for front controllers
    RewriteRule ^app_dev.php - [L]
    RewriteRule ^app.php - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    # Change below before deploying to production
    #RewriteRule ^(.*)$ app.php [QSA,L]
    RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>

It works fine on my local machine, just not on my development server, any ideas why?

My /cache and /logs directories are both have 777 permissions and are owned by www-data:

drwxrwxrwx+ 4 www-data www-data 4096 Mar 15 11:46 cache
drwxrwxrwx+ 2 www-data www-data 4096 Mar 15 11:05 logs

dev and prod within these directories are exactly the same.

2
  • Are you trying to open the dev environment in the dev server from the server itself or from your local computer? Commented Mar 15, 2013 at 12:20
  • I'm browsing to the dev environment (app_dev.php) which is hosted on the dev server from my local computer Commented Mar 15, 2013 at 12:39

1 Answer 1

7

Check your app_dev.php it has a restriction to deny access to the dev environment from other computers than the server itself.

This is for security reasons, if you deploy to a production server and a user would have access to dev env, then he/she could know a lot about your application.

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

You must add your IP to that array, or remove the whole thing (I wouln't recommend that).

Always remember passing the dev variable to AppKernel. $kernel = new AppKernel('dev', true);

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks @xr09. I have 3 external servers, development, staging and production, would you recommend I use the dev environment on my development server then or not?
@user1961082 In your dev server is ok (it is made for that after all), but remember setting the rules on deploy to avoid an accident in the production one.
so dev env for local machine and development server, test for staging and prod for production? I'm using Capifony with the Capistrano multi-stage extension so can I set this within my development.rb script or do I have to do it directly in app_dev.php?
You should edit your app_dev.php to add your local IP, yes dev is for local and dev. server, test is almost the same without the debug toolbar and the verbose logging, check you app/config/config[dev|test].yml and check the differences to see what is enabled in each environment.
OK I've realised that app_dev.php is not being deployed. It's within my GIT repository in github but when I deploy using Capifony for some reason it's not pulling this file from github?!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.