3

I want to deploy a local craftCMS 3 website to a server, but I didn't manage to get answers to some of the questions I have rightnow on Google search. So I hope you can help me with this and can help me finding the right / a better workflow to do these things instead of me reinventing the wheel.

I have the website build locally and want to deploy it. I installed composer on the webserver via SSH by putty (Win) and installed Craft 3 on the server with composer and the craft webinstaller whithout any problems. But that's obviously just an empty craftcms and not the locally build cms.

These are the questions I have right now:

1) What's the preferred way to install a build craft website on the server? Do you use the craft installer or just copy all local files of the project to the server by FTP?

When creating a new craft project with composer the 'public' files are in 'web'. So if I install a new craft project with composer on the webserver inside public_html, the public files will be in domain.com/project/web or in domain/web if I use public_html as a path. But in both cases some critical files, like the config files with passwords and all, will be in the public_html folder.

Of coarse I use htaccess to protect things, but I'm not sure this is the right and secure location to have this folderstructure on the server as meant to be and wonder if the project should go on a higher folder instead with only 'web' exposed on public_html.

2) What's the right location on the server to install the craft project to to keep everything secure, like having config, vendor and all 'out of sight'? Do you guys install craft directly in the public_html folder, or on a higher parent folder? And in case of the latter do you only have the 'web' folder inside public_html somehow (how to do that?)? So what's the right/preferred way/location to install Craft3 in a secure way?

With an older CMS/framework I used I just copied local files by ftp to deploy. But it seems like using composer is a better way to do this and like to improve my workflow.

3) If you make changes to the website locally, how do you deploy them once the website is setup on the server? Do you just use ftp to upload your changed files (and update the database) or is there a better way to do this with composer?

I like to do things in a way that works best and the CMS is meant for instead of reinventing the wheel and do things differently than the 'standard'. Hope you guys can help. Thanks in advance!

2 Answers 2

3

At the risk of "link" answers, we talk about different deployment strategies here:

...and there's a writeup of deploying Craft CMS here:

It's hard to do a TL;DR on this, because it's fairly involved, but essentially ignore your vendor/ directory, and do a composer install on your production/staging server to install the vendor/ directory there, synced up with your composer.lock

Using some kind of deployment tool like Forge or Buddy.works will also make your life easier.

2
  • Thanks for your help. I still wonder what the second link should be, because that's now the same url as your first link, but yesterday I was listening to your podcast and it's pretty great! I'll listen to some more later. I am one of the users that uses git for every project, but somehow I didn't know about the trick with hooks to update the server. I'm trying that out now. Maybe Forge and Buddy.works will be the next step, but first setting up git on my server! Thanks
    – Friksel
    Nov 24, 2018 at 17:40
  • I updated the link to the second one; sorry. It should have been this: Setting up a New Craft CMS 3 Project Nov 24, 2018 at 22:33
2

I install Craft CMS generally via composer on my local system and copy the files preferably via git to the server. I have one project where i have to copy files via ftp, thats a bit more complicated but it works. If i make updates locally i can see, what files changed in my git repository and know what i have to upload via ftp. Just make sure you add all important files to your git repo (included /vendor).

Regarding the web root: Copy all files to /public_html on your server and make sure the web root then points to the Craft /web directory!

1
  • Thanks for the confirmation on the /public_html. I thought I read somewhere that craft needed to be in some higher folder. But it looks like that's not needed. Which makes everything a lot easier. I am trying now to setup my git system to expand to remote pushes. Somehow I didn't know about it before, but it seems like a great solution! Thanks
    – Friksel
    Nov 24, 2018 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.