How to deploy Symfony 2 project on server?
From time to time I like to perform my hobby projects using new technology. I suppose it is the best to learn new techonology. So for my small search site for phone cases using Amazon API over Amazon Market, I decided to use PHP Symfony 2 framework.
Overall impression of this framework I suppose is theme for other article. I faced with deployment problem - searching over internet and manuals didn't give me exact recipe to deploy sumphony 2 project to production server. At last I find a way to deploy project on my own:
- You need to clear cache and how to do it depends on kind of hosting that you have:
-
if you have SSH console, then you can do it on hosting after step 2;
-
if you haven't - than do it localy just run command:
php app/console cache:clear --env=prod
-
Suppose you have on you hosting folders looks like this youdomain/public_html, then in public_html must be located all web files. So you must upload all from symfony project (folders: app,src,vendors, bin; files: deps, deps.lock), except folder 'web' in folder 'youdomain'. Everything from folder 'web' upload to folder public_html.
-
Check CHMOD for folders app/cache and app/logs, there should be write access.
-
If there is no file .htaccess in public_html, then create it and add such code in it: https://raw.github.com/symfony/symfony-standard/master/web/.htaccess
-
Now you should use youdomain.com/index instead of youdomain.com/app_dev.php/index, that you use locally. If site still did not work, then you can open file web/config.php and find code where perform check for IP, you find there only ip 127.0.0.1, add your current ip to this list and upload new config on server. Then you can open path yourdomain/config.php and check what's wrong.
-
If config.php shows that everything ok, but site still didn't work, you can open app_dev.php to debug: open app/app_dev.php and your ip as specified for config.php. Now you can run scripts as localy using app_dev.php.
During searching answer for this problem I start question on stackoverflow, where described all initial situation: http://stackoverflow.com/questions/12462220/steps-to-move-symfony-2-project-to-hosting