Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Steps to move Symfony 2 project to hosting?

Tags:

symfony

I have read a lot of articles and questions about deploying of Symfony 2 project on a production server, but still, this is not clear. Deploy of Symfony project looks like a hell - nobody knows how to do this correctly. I suppose the best topic I see was Deploying a Symfony2 project, but still, a lot isn`t clear. I read it, and find out that in that question person added his own IP to a list of allowed IP, but this means that only this IP can access this site, but I need to allow everybody use it.

And how can I make site working with path www.mydomen.com, instead of www.mydomen.com/web/app_dev.php/index (I can correct path via Symfony, but it works after app_dev.php and via hosting, but how can it work before /app_dev.php? It seems like app-dev.php should always be in my path).

So how should I correctly transfer developed project from local server to production server step by step, please?

like image 532
sphinks Avatar asked Sep 17 '12 15:09

sphinks


1 Answers

OK, I find out how to correctly deploy app on shared hosting. Here it is:

  1. 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 then do it locally: run command php app/console cache:clear --env=prod.
  2. Suppose you have on you hosting folders youdomain/public_html, so in public_html must be located all web files. 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 should be upload to folder public_html.
  3. Check CHMOD for folders app/cache and app/logs, there should be write access.
  4. 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
  5. Now you should use youdomain.com/index instead of youdomain.com/app_dev.php/index, that you use locally.

If your site still did not works, you can open file web/config.php and find the code where the check for IP performed, you find there only IP 127.0.0.1, add your current IP to this list and upload new config on a server. Then you can open path yourdomain/config.php and check what's wrong. If config.php shows that everything ok, but your site still didn't work, you can enable app_dev.php to debug: open app/app_dev.php and add your IP to the list as for config.php done before. Now you can run scripts as locally using app_dev.php.

like image 183
sphinks Avatar answered Oct 22 '22 18:10

sphinks