New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Deploying Statamic 3 site from localhost to shared host environment

Ron van de Crommert October 22, 2020 by Ron van de Crommert

I'm looking for some guidance on moving a Statamic 3 site developed on my computer (localhost) to a production environment on a shared host (HostGator in my case, partly because it's supposed to play nicely with Statamic out of the box). I've been trying to figure out how to do that, but I'm having a hard time making things work. I'm no expert, but not a completely novice either.

I developed my Statamic 3 site (let's call it 'MySite') on localhost, using Laragon on Windows 10 as the web server, with Apache and PHP 7.4. I set the Statamic's 'public' folder as the webroot, and everything looks great and is working as expected on 'localhost'.

I'm now ready to deploy this site to my shared host, HostGator. I quickly figured out there was a lot more to it than simply copying everything from the local 'MySite' folder to the web server. I've been looking at pages like these to get a sense of how to do that exactly:

First thing I did was install Laravel 8 on my HostGator web server using the Softaculous installer, which is available on HostGator's cPanel. There are basically three options to install Laravel on my shared host:

1) Directly in 'public_html', so all Laravel directories are directly under 'public_html'.

2) In a subdirectory (say, 'laravel') under 'public_html', so public_html/laravel/.

3) In a directory outside 'public_html', so something like: /laravel/ and /public_html/.

Some blogs suggest option 3, but Softaculous on HostGator actually doesn't allow option 3; you can only install Laravel under 'public_html', either directly or in a subdirectory. Which Laravel installation approach should I use?

Next step: upload the entire 'MySite' directory to the HostGator server. Where should I upload it to?

1) Into the Laravel directory, so "merging" the 'MySite' directory with the Laravel directory if you will.

2) Into a directory outside 'public_html', so /MySite/ and /public_html/.

In either case, if I'm not mistaken, the content of MySite's 'public' directory will need to be copied to the 'public_html' directory, or a symlink needs to be created between 'public' and 'public_html'. Some blogs suggest that you should put the 'public' directory content in a separate subdirectory under 'public_html', so something like 'public_html/MySite'. Would you recommend that, or would you put everything directly in 'public_html'?

The final step, according to the web pages I've been reading, is to edit some PHP files, so things point to the correct locations. The thing is I can't seem to figure out what exactly needs to be modified where to make things work for me. I've tried following the instructions on various pages, but I can't get my site to work on HostGator.

Am I missing something here? Is all this a lot easier than it seems to be? This seems like a very common scenario (develop Statamic 3 site on localhost and then deploy it on a shared host). It's been very frustrating to have this beautiful tool to create a site, but then having such a hard time deploying it to a production environment. The documentation doesn't seem to provide any step-by-step instructions on deploying a Statamic 3 site to a shared hosting environment. This might scare off a lot of new Statamic users, who are otherwise excited to learn more about this awesome tool, particularly now that the Statamic core is free to use.

Any guidance would be much appreciated.

Thanks! --Ron

>>>>>>> Unanswered <<<<<<<
17 Replies