Using Symfony on a Shared Host

Screen Shot 2014-11-18 at 1.55.52 PM Most of my clients are on shared hosting. I advise the start-ups I work with to start on a good, respectable (just about anything besides GoDaddy or HostGator) shared hosting and save the expense.

I've heard some people say they can't use Symfony on their shared hosting because Symfony requires command line access to use the tools. You may not be able to use these tools on your online hosting, but I usually build the site locally where I can use the tools and then ftp the files that are needed to the shared hosting account.

The next obstacle is the architecture and folder layout of symfony. Most shared hosting accounts use a different name for their web folder. Symfony2 makes this easy by allowing you to change the name of the folder without any problems.

If you move the web folder then you will need to change the paths to this folder in the front controller. I don't suggest, however, that you put the app, src, and vendor folders inside the web folder since this opens them up to the public.

If your shared hosting uses cpanel. Just change your local web folder name to public_html. FTP everything from that local public_html folder to the shared hosting public_html folder when you are ready to deploy. Then FTP the app, src and vendor folders from your local machine to the root folder of your shared hosting - usually the folder containing the public_html folder.

As long as your public_html folder is in the same folder with your app, src and vendor folders you shouldn't have to change anything. If they aren't then you will need to change the paths to these files in your front controller.

Each time you FTP changes to your server you should clear the cache for your production environment. Assuming you are using prod for your production environment, you can just delete the app/cache/prod folder and all it's contents. Then pull your site up in your browser and the cache will be rebuilt.

Anytime the cache needs to be cleared, you can just delete the app/cache/prod folder and pull up the site in your browser.

Everything should work fine on your shared hosting assuming the hosting provider has the resources required for Symfony 2.

Disclosure: Some of the links on this site are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission.

Comments

  1. says

    Hello Cindy,

    I currently fight with a symfony2 deploy on a shared hosting.

    The issue that I’m encountering is how to make http://mydomain.com to use the symfony prod front controller (app.php)? From what I know, having a public_html folder on a shared hosting you tipically add an “index.php” or “index.html”, etc file there, but that doesn’t fit the symfony2 architecture.

    Also, regarding your post: “If you move the web folder then you will need to change the paths to this folder in the front controller” – There is a cookbook entry for that: http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html#override-the-web-directory.

    Cheers,
    Florin

    • Cindy says

      Florin, Make sure you have the .htaccess file set up correctly inside the puglic_html folder. This line will redirect it to the app.php instead of index.php:

      # Rewrite all other queries to the front controller.
      RewriteRule .? %{ENV:BASE}/app.php [L]

  2. says

    After I checked that .htaccess file I noticed that everything is ok, the line is there.
    I’ve then tested another route that worked (domain/test-route).

    Guess what? The whole thing was just a “browser caching” issue. :)) I’ve opened an incognito window and hit the main domain and the thing worked as intended.

    Thanks!

    • Cindy says

      Great! Glad you got it working. Also, in case others may be having the problem, it could be a Symfony cache problem as well. So, they should try clearing the Symfony cache too. Thanks for leaving an update!

    • Gerardo says

      Hey there! I am having problems deploying my Symfony project on a shared hosting – hostagator.
      The website is visible but all the images and other assets do not seem to work. They are not found. Can you please tell me how you achieved deploying it on a shared hosting.
      Thanks

  3. Jim says

    I am using Symfony on a Bluehost shared host. Everything has been working fine (still in beta), but I am now trying to use Bluehost’s Free Shared SSL Certificate for Registration, Login, etc.

    As per the instructions, I used the following URL to access the Sign In page:

    https://box####.bluehost.com/~username/login

    This works fine. However, after I am Signed in I would like the URL to return to my domain name (e.g. http://example.com/).

    This does not happen. The page goes to: https://box####.bluehost.com/~username/

    And then whatever page I go to the URL remains: https://box####.bluehost.com/

    Do you know what the best solution is to this problem? Is this a Symfony issue or a Bluehost issue?

    Do you know how to revert back to my domain name from the Bluehost domain name?

    Thank you for any help.

    Jim

  4. Jyotsna says

    I want to upload my Symfony project to my shared hosting. Folder structure as follows:

    public_html/projects/Symfony/MyAppName

    how to configure paths now?

    • Cindy Cullen says

      You should be able to just change the paths to the app, src and vendor folders in your front controller.

Leave a Reply

Your email address will not be published. Required fields are marked *