How To Install Your Symfony App On A Shared Host To Your Root Domain With No vhost.conf Access
If you upload your new symfony site to a shared host, and put all of symfony's files into your ~/public_html/ directory, the symfony application is served up with a "/web" at the end. There are a few ways to serve your site up at the root of the domain without having all of your symfony files stored in public_html. Here is one way you can to get around this issue without reinstalling symfony and without access to your vhost.conf or httpd.conf file.
1. Copy all the symfony files from ~/public_html over to a new ~/symfony directory:
cp ~/public_html/* ~/symfony
2. Move the ~/public_html directory to a backup:
cp ~/public_html ~/public_html.bkp
3. Create a new symlink that points ~/public_html to symfony's web directory
ln -s ~/symfony/web/ ~/public_html
4. Now, for some reason the .htaccess file from the old public_html folder didn't get copied. So, make sure copied it over to ~/symfony/web/:
cp ~/public_html.bkp/.htaccess ~/public_html # note the new public_html folder actually points to ~/symfony/web
5. Finally edit the .htaccess file in the ~/symfony/web folder so that all requests are directed to just "index.php" file rather than "web/index.php" like it used to be:
RewriteRule ^(.*)$ /index.php [QSA,L] #RewriteRule ^(.*)$ /web/index.php [QSA,L]
6. One last thing... Make sure to change permissions on the cache and log folders:
chmod 777 -R ~/symfony/log ~/symfony/cache
How to host multiple projects under subdomains
I generally will upload my symfony projects to a staging area while I am working on them so I can show clients progress. The process is really easy once you get used to it, and it requires ssh access.
Goal: host multiple symfony projects under different subdomains on the same hosting account.
1. Create the subdomain using your web host's control panel. If I set up the subdomain "app1.mydomain.com", it will generally point to a new directory in my public_html folder with the same name (app1).
2. Upload symfony project to my root directory (NOT public_html, but the level above that). In this example the path is:
3. Now, I need to point the folder created by the subdomain in step 1 to my new project's web folder uploaded in step 2:
# cd ~/public_html # rm -rf app1 //remove the original directory created by subdomain # ln -s /home/[myusername]/app1/web app1 //make a symlink to my projects web directory
4. You're done!