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"