Reputation: 2177
I have some problems with Symfony 2 application deployment. I have import all files I need on my OVH shared server, but some errors occured like css and js files not found (internal server error for example) or error like Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://my-server/css/458dafd_bootstrap-theme.min_1.css"
.
Notice that I have installed the CoresphereBundle in order to have a console in my browser when my application is iploaded on my server, I have access to the console only on dev environment.
This is step by step what I did in order to deploy my application:
1 I updated my application and vendors with composer (because I have no ways to install composer on my server)
composer.phar update
2 I clear the dev cache php app/console cache:clear
3 I clear the prod cache php app/console cache:clear --env=prod --no-debug
4 I install assets php app/console assets:install web
5 I dump the assets php app/console assetic:dump web
6 I uploaded my symfony application on my server.
7 Once the files are uploaded in web/app.php
I I authorize
the prod debug
$kernel = new AppKernel('prod', true);
8 Then in web/config.php
I remove this block
// …
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('This script is only accessible from localhost.');
}
So, on my server, if I would like to go to http://my-server/web/config.php
it works well, so I see if my server is compatible with symfony. the only thing that appears is Set short_open_tag to off in php.ini*.
9 I set the access rights for the app/cache
and app/log
folders to 777 on my server, it allows the applications to write in these folders.
10 In web/app_dev.php
I write this code, in order to allow the dev mode for my IP adress and so have access to the console bundle
// …
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
'121.457.719.2' //a random ip adress it's just for you to understand
))) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
11 So I have access to the dev environment on my server, all works well, and no errors occured here. To access to the console bundle, following to the bundle documentation, I have to wrote http://my-server/web/app_dev.php/_console
(see the routing code here):
_console:
resource: "@CoreSphereConsoleBundle/Resources/config/routing.yml"
prefix: /_console
But this routes does not exist, If I wrote this url, nothing appear in my browser:
However, by the config.php
, I have access to app_dev.php
by following the Bypass configuration and go to the Welcome page
link:
I click on the link and I arrived on app_dev.php
. Like I said before, no errors occured in this environment, except for the console route. But I could have access to the console by clicking on the console logo under the symfony debug toolbar:
This is the url for the console when I click on the logo under symfony debug toolbar: http://my-server/web/app_dev.php//_console/_console
, I would like to understand why?
Then when I would like to make some commands another error occured: [error] Internal Server Error
in the console:
If I try to use the router debug php app/console debug:router
, I have this:
and with the php app/console debug:router | grep _console
:
So, there are the problems I have with my symfony application.
UPDATE
I resolved the problem of the console bundle. In fact my server does not use the same php version of my symfony application, I have to set this in the .ovhconfig
at the root of my /www
folder.
/www/.ovhconfig
:
app.engine=php
app.engine.version=5.5
http.firewall=none
environment=production
Now when I would like to access to the production environment I have these errors concerning all my assets files (css/js/images, a 404 not found):
Failed to load resource: the server responded with a status of 404 (Not Found) ->
http://my-server.com/bundles/fosjsrouting/js/router.js
Uncaught ReferenceError: fos is not defined -> routing:1
Failed to load resource: the server responded with a status of 404 (Not Found) ->
http://my-server.com/css/45898d_dataTables.min_7.css
I don't really understand, the files are indeed at the root of the app, e-g I have no folder css or js or etc in http://my-server.com/
. These folders are in http://my-server.com/web/
. Where is the problem?
When I access to the console, this is the command I made:
1 cache:clear
2 assets:install web
3 assetic:dump web
EDIT: solution works
I understand that the assets target a /css
/js
/images
etc folder at the root of my server, so I replace the css and js files to the root of the /www
server folder, e-g in the /www
folder of my server I have this:
//my server
/.ssh
/www /*http://my-server.com/...*/
/app/
/bin/
/css/
/fonts/
/images/
/js/
/src/
/vendor/
/web/
/.htaccess
/.ovhconfig
/composer.json
/composer.lock
/composer.phar
Why my symfony application tagets the assets here?
Upvotes: 1
Views: 3352
Reputation: 626
Have you tried to use the Symfony command line routing debugger?
php app/console debug:router
That will output all the routes the symfony app knows about and you could try piping it into grep
to see if you're trying to use the wrong path to hit the _console route.
php app/console debug:router | grep _console
Upvotes: 0