Dev to prod + mutualized hosting deployment

New topics about Symfony 2 should go here

Moderators: dcobalt, tiagojsag

Dev to prod + mutualized hosting deployment

Postby zealot » Sun Apr 08, 2012 12:00 am

Hi all !

Can anyone provide me with a kind of tutorial regarding how to make a Symfony2 project ready for production. My app is fully functional in development mode but I can't load it in production mode. The only how to I've been able to find until today is the one made for Symfony1. Once the app is ready for production, I'll have to deploy it on a mutualized hosting. I also need more information about the folder tree I have to upload.

Thanks in advance.

zealot
zealot
Junior Member
 
Posts: 3
Joined: Fri Apr 06, 2012 10:58 pm

Re: Dev to prod + mutualized hosting deployment

Postby blogsh » Sun Apr 08, 2012 10:54 am

I have create a "deploy.sh" script for this purpose:

Code: Select all
mkdir -p deploy # Create deploy directory
cp -r app deploy # Copy /app
rm -rf deploy/app/logs/* # Remove logs
rm -rf deploy/app/cache/* # Remove Cache
cp -r src deploy # Copy /src
find vendor -name .git -type d | xargs rm -rf # Slim down the vendors (remove git history)
cp -r vendor deploy # Copy vendors now
cp -r web deploy # Copy /web


Additionally you have to make sure that you don't override or update the parameters.ini on your web host. You should also clear the cache directory on your webspace.
blogsh
Faithful Member
 
Posts: 501
Joined: Thu Mar 03, 2011 9:35 pm
Location: Germany

Re: Dev to prod + mutualized hosting deployment

Postby fernandonn » Mon Apr 09, 2012 1:31 am

Blogsh script is great !
But if you do not have bash installed (aka you are a windows developer) will be of no use for you.

But the script is fairly easy to read and understand.
Basically, you don't have to do anything to have a production ready application. Just upload to your hosting all the files (including symfony's files and you are ready to go)

Just some notes to...
There are things that you don't need to upload and blogsh script does a good work erasing them.
the content of app/logs folder do not need to be uploaded
the content app/cache folder do not need to be uploaded
if you have .git folders (ususally hidden folders) do not need to be uploaded

the important folders are: vender, src, app and web.

Just one more note.. you should configure the document root of your hosting to point to web folder. But some providers have it hardcoded to http_public or something like that and you can't change it.

If that's your case, just rename web folder for http_public or whatever your hosting have configured.
good luck !
User avatar
fernandonn
Junior Member
 
Posts: 20
Joined: Mon Oct 24, 2011 6:37 am
Location: Buenos Aires

Re: Dev to prod + mutualized hosting deployment

Postby zealot » Mon Apr 09, 2012 7:27 pm

Thanks very much guys !
It seems that we the line 7 (use Symfony\Component\HttpFoundation\Request;) of the app.php file is reached, an error occures (Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or ...).
The php version available on my mutualized hosting is the 5.0.77 one. So it's not compatible with the 5.3 within Symfony2. I think the is because I get this error message but I have to investigate to be sure.
I will then try again to proceed as you told me.
zealot
zealot
Junior Member
 
Posts: 3
Joined: Fri Apr 06, 2012 10:58 pm

Re: Dev to prod + mutualized hosting deployment

Postby blogsh » Tue Apr 10, 2012 5:29 pm

Symfony needs at least PHP 5.3.2!
blogsh
Faithful Member
 
Posts: 501
Joined: Thu Mar 03, 2011 9:35 pm
Location: Germany

Re: Dev to prod + mutualized hosting deployment

Postby zealot » Tue Apr 10, 2012 7:56 pm

Ok guys, PHP version has been updated to 5.3.4 and I can reach the site now ! I changed the rights to 777 on /app/cache and /app/logs. Do you think I have to change other rights ?
zealot
Junior Member
 
Posts: 3
Joined: Fri Apr 06, 2012 10:58 pm

Re: Dev to prod + mutualized hosting deployment

Postby althaus » Wed Apr 11, 2012 5:42 pm

An alternative approach is to go by Git. Then you can deploy a project by just pushing to your production remote. :D
althaus
Faithful Member
 
Posts: 605
Joined: Tue Oct 18, 2011 2:20 pm
Location: Germany


Return to General Symfony 2 discussion

Who is online

Users browsing this forum: Bing [Bot] and 4 guests