Steps to move Symfony 2 project to hosting?
Asked Answered
B

1

13

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?

Bax answered 17/9, 2012 at 15:13 Comment(1)
This is how I do it #25888425Stamp
B
21

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.

Bax answered 20/9, 2012 at 8:9 Comment(3)
I did that, but I have got this error: Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/.../public_html/app.php on line 3. In this line is: use Symfony\Component\ClassLoader\ApcClassLoader;Closeknit
It does not connect with deployment, seems to be some syntax error.Bax
Symfony's web folder must exists. Instead of change web's folder name to public_html, it's better to make a symbolic link called public_html which will be pointing to web (public_html -> web). In other case, several commands will complain about missing web folder, e. g. assets:install.Bulbar

© 2022 - 2024 — McMap. All rights reserved.