Deploying a Symfony Project on GoDaddy Shared Hosting
Posted by gfaraj on April 25, 2008
Recently, I had the task of deploying my Symfony project on my GoDaddy shared Linux hosting. I ran into some problems, and I thought I would share in hope of helping any other poor soul who might run into the same problems.
First of all, you should follow the steps here. It does not require you to freeze the project to deploy it. I find that useful for projects that are not yet stable and need to deploy a “beta” version. Also, make sure you have PHP 5 as the default in your GoDaddy Hosting settings.
Next, you need to modify the .htaccess file. Go ahead and uncomment the RewriteBase line in the default symfony .htaccess file:
# uncomment the following line, if you are having trouble # getting no_script_name to work RewriteBase /
This should prevent ‘www.myhost.com/mymodule’ from getting a 404 error from GoDaddy. Now, at least you might get forwarded to your 404 module/action. This is, at least, some proof that you’re moving forward. If you turn on logging (logging is turned off for production configurations by default), you might see the following:
1 Info Context initialization 2 Info Controller initialization 3 Info Routing match route [default_index] "/:module" 4 Info Request request parameters array ( 'module' => 'index.php', 'action' => 'index',) 5 Info Controller dispatch request 6 Info Controller action "indexphp/index" does not exist
As you can see, the module/action resolution is very wrong. This, of course, results in Symfony forwarding to your 404 module/action. Well, it turns out that adding one line to your php5.ini fixes this.
cgi.fix_pathinfo = 1
This worked nicely for me, and I hope it works for you. I’m posting my full php5.ini and .htaccess files for completeness.
Addendum
It has come to my attention that some people are still having problems after making the changes described here. You might want to try one more change. In your application’s config/settings.yml file, set the following setting:
prod:
.settings:
path_info_key: REDIRECT_URL
php5.ini
register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" memory_limit = 20000000 session.gc_maxlifetime = 72000 #log_errors = On #error_log = php_error.log #display_errors = On #error_reporting = E_ALL magic_quotes_gpc = false cgi.fix_pathinfo = 1 [Zend] zend_extension=/usr/local/zo/ZendExtensionManager.so zend_extension=/usr/local/zo/4_3/ZendOptimizer.so
.htaccess
Options +FollowSymLinks +ExecCGI
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
# big crash from our front web controller
ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"
Michal Thomka said
Thank you very much for this helpful post!
Spent couple of hours trying to figure this out, it was already giving me quite a headache
All the best
Michal
gfaraj said
Glad it helped you
Zvi Landsman said
My top level directory on GoDaddy is my public html directory – this poses a security risk if all of my files are public.
Is there a way to configure this on GoDaddy (economy plan), or set up .htaccess to prevent these files from being accessed?
gfaraj said
Unfortunately, GoDaddy has that retarded flaw. I have no idea if they have an option to change it. You could probably write a .htaccess rewrite rule to protect the files from being accessed though.
bob said
3r0rjZ hi nice site thanx http://peace.com
Alexwebmaster said
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru
Franck said
Thank you !
Important: in sf1.2 “path_info_key: REDIRECT_URL” is in the factories.yml file not in the settings.yml
XRumerMonstroZ said
Hi!
Gimme url for downloading XRumer 5.0 Palladium crack!
Thank you…
Very-very much.
I’m so need this program for advertise my web projects!!! This software is the best thing for online promo and mass posting, you know…
And, dont send me XRumer 2.9 and XRumer 3.0 – that versions are too old!
P.S. Google cant help me((((
sapumal said
Thank you very much. I had the exact problem and this method worked for me.
Jen said
The Symfony site mentions how shared hosting can be “unsafe”… is GoDaddy affected by the things they mention or can I use Symfony and not worry? I have GoDaddy shared as well and I’m able to navigate all over the place in SSH. I can see other user’s account names (but not their files)… I don’t really know enough about security to know if that means I’m vulnerable. Any help would be appreciated.
Dreceinge said
hmm. attractive )
car accident lawyer jacksonville said
i must say, your blog is very good, i will be checking back to read more
taunlinuere said
I really enjoyed reading your article, keep up posting such interesting stuff!
Sylvester Hartnett said
Fairly good post, genuinely enlightening information. Never thought I’d discover the information I want right here. I’ve been scouring throughout the internet for some time now and was starting to get disappointed. Thankfully, I stumbled across your blog and acquired precisely what I had been browsing for.
Apul said
Where to put php.ini in godaddy server. I have set,
/home/myname/public_html/article/web to my document root of domain http://www.mydomain.com
Please suggest.
Also, I am getting this error, after all the steps:
Fatal error: Class ‘BaseFormPropel’ not found in /home/myname/public_html/article/lib/form/base/BaseArticleForm.class.php on line 12
But, When I checked that using FTP, file was there.
Please suggest.
Sandeep Raul said
Today i spent entire day fixing this issue: either the index page was shown for any directory or page not found error. Tried all possible stuff but nothing was working out. Luckily got this URL on Google and solved my problem.
Thanks a ton!
Momo said
Thanks! This helped a lot, and in the spirit of having this documented, I’d like to add that firstly, I had to make a php5.ini file since the default one was php.ini. If you are using php5 you must create this file. Also to have changes take affect, you have to launch your godaddy control panel, and go to content > processes and click End Web. Documented here
Priya Infotech said
Finally it’s working.
I did tried everything and still it was not working. I did read this page 100 times but still it was not working. Luckily I read Momo’s comment and after that I just did what godaddy told us to do and now it’s working fine. Thanks to everybody and special thanks to Momo.
mantegna said
Lorem ipsum dolor sit amet consectetuer id ut consectetuer elit orci. Ut leo eu natoque Sed ante quam laoreet interdum nulla at. Suscipit eros In magnis metus Nam est Maecenas lobortis mauris facilisi. Pretium condimentum leo ligula id tempor vel Donec nulla tempus commodo. Sem in consequat sed quis consectetuer.
Ipsum Aenean ut ipsum quis sed at feugiat dolor id semper. Cursus quis nibh sociis laoreet Fusce Vivamus rutrum Sed nulla at. Congue Suspendisse pellentesque ut quis orci Phasellus non mollis interdum consequat. Augue justo pretium id nibh adipiscing habitant ut tincidunt Nullam lorem. Orci faucibus lorem dictumst at Quisque tristique amet.
In urna volutpat Aenean dictum hac ut ac dictumst Aenean Donec. Augue Sed magna wisi hac justo sociis felis at mauris Sed. Integer gravida Sed vel tristique velit Nullam lacinia Curabitur faucibus tincidunt. Ullamcorper neque dictum ut a penatibus id tempus nulla felis turpis. Et ipsum nec Vestibulum pede cursus gravida ante Maecenas Vivamus eu. Sapien justo elit massa.
Sed at condimentum arcu malesuada ut ipsum Donec nunc felis Vestibulum. Pretium Integer id quis Fusce faucibus Praesent id egestas nec et. Ipsum Nunc libero mi odio ipsum semper Quisque egestas mauris adipiscing. Mauris Nulla mus Vestibulum dolor eros tortor nisl Donec Sed tellus. Eu vel Donec nibh ut consequat id Phasellus interdum sem turpis. Ut ornare et.
Justo urna malesuada dictum augue Maecenas velit et buy tickets Aenean Vestibulum condimentum. Sed ridiculus interdum diam sed Pellentesque nisl et ultrices aliquam Quisque. Sed Aliquam feugiat fames libero massa condimentum pulvinar sed metus fringilla. Neque tortor Vestibulum tincidunt consectetuer auctor sed sem a Phasellus tempor. Aliquet interdum condimentum tortor nulla Sed et auctor eget porttitor dui. Fames Proin at Vestibulum a ante vitae condimentum Lorem Sed Cras. Vestibulum.
Risus lorem aliquet tellus adipiscing ante Sed orci hac porta nibh. Et ut suscipit Nam natoque diam Suspendisse tellus id senectus tempus. Dictum tincidunt Nulla congue Sed laoreet Aenean ac Aenean commodo felis. Fusce congue dui at nec wisi Curabitur ante condimentum elit nunc. Curabitur elit nibh porttitor et tincidunt et Phasellus.
Porttitor vitae rhoncus odio sollicitudin suscipit lacus sagittis justo tellus ac. At Quisque at fringilla laoreet et Vestibulum Aliquam euismod leo tellus. Quisque Vivamus at Proin id lorem wisi tellus Donec justo tincidunt. Commodo neque mollis vitae tellus ut Nam senectus id Nam pede. Sed ipsum sagittis senectus vel amet enim id nulla semper Morbi. Quisque dui malesuada a Phasellus Sed eget et et Nulla.
Non pulvinar porttitor volutpat egestas est pellentesque quis nibh volutpat Quisque. Amet semper Aliquam congue orci pellentesque nibh neque nibh porta tellus. Sed tortor malesuada semper pretium sociis leo laoreet Maecenas Vivamus hendrerit. Phasellus ut penatibus eget dui elit felis dui in consectetuer Duis. Nulla et turpis metus non adipiscing.
Tom @ Google serach redirecting fix said
Tom @ Google serach redirecting fix…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
wehostia.com said
wehostia.com…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
web hosting said
web hosting…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
domains said
domains…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
Epilogi Domain Name said
Epilogi Domain Name…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
Thakimhost said
Thakimhost…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
singapore vps said
singapore vps…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
furniture stores at tucson az said
furniture stores at tucson az…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…
Cheapest hosting! Only 0.01 USD / 1st month. Just use the promo code: '1cent' said
Cheapest hosting! Only 0.01 USD / 1st month. Just use the promo code: ’1cent’…
[...]Deploying a Symfony Project on GoDaddy Shared Hosting « A Coder’s Corner[...]…