Problem getting site to work with Git repo
I have a site that I would like to start managing with Git on cPanel. I know how to get the site up to the server so no issues there. The issue is that the site is located in a folder "/project/public" and the site serves up files from the document root of "/public_html".
I know that I could change the document root, but everything I read says that is not preferred for the primary domain. Since we use AutoSSL, I noticed we have a new folder in "/public_html" directory called ".well-known" (along with cgi-bin). This seems to prevent me from using a symbolic link for "/public_html" to point it to the "/project/public" directory.
What is the best way to handle this? I know many people are now using Git instead of FTP. What is the preferred method? If I remove the folders in the "/public_html" directory and create a symlink, won't it just recreate it during the nightly CRON? How should I best be using Git and cPanel together to serve up a site correctly?
Any advice is appreciated.
-
Been looking all morning and kind find an answer. Can anyone provide any advice? 0 -
Have you seen this documentation? How to Host Git Repositories on a cPanel Account - cPanel Knowledge Base - cPanel Documentation 0 -
I am trying to do this in such a way to not break cPanel on upgrades, migrations, etc.. Looking for the approved method. That help doc is missing a final step showing how to make the project/example the LIVE website. How should we do this? Should we use a CRON to copy the repo to the public_html folder or something? I know you can adjust the document root, but I heard it can break upgrades and also won't work with cPanel migration tools, etc.. I was told you should not do this. Is there a better way that will no break cPanel features? You must edit the file: /var/cpanel/userdata/USERNAME/DOMAIN.COM /var/cpanel/userdata/USERNAME/DOMAIN.COM_SSL and change the line: documentroot: /home/USERNAME/public_html to documentroot: /home/USERNAME/project/example and then run: /scripts/rebuildhttpdconf service httpd restart 0 -
In an ideal world, your domain.com would be an addon domain, not the primary domain you started the account with. Then the document root location would be manageable from the Addon Domains feature. I realize that's not the most helpful thing in the world, but that's the migration-safe upgrade-safe canonical way to do it. I apologize that we don't make that clear in our communication. (WILL FIX) As an aside, we are currently working on the Allow users to install websites from version control feature for v72 and later which would embrace what you're trying to do by deploying your work via git. Would you like to be a part of the beta program for our work and play with our work before release? 0 -
It occurs to me as I think about this more...and as I talk this out with my peers here inside cPanel and read up on Statamatic...that, if there's the means to tell Statamatic to render into ~/public_html (rather than $PROJECT_ROOT/public, it's default behavior), you could git-clone your project into your ~ and that would have the net-effect you want. 0 -
It occurs to me as I think about this more...and as I talk this out with my peers here inside cPanel and read up on Statamatic...that, if there's the means to tell Statamatic to render into ~/public_html (rather than $PROJECT_ROOT/public, it's default behavior), you could git-clone your project into your ~ and that would have the net-effect you want.
I was able to PUSH into the /public_html just fine. Everything is in document root and protected with .htaccess. Looks good so far. The .git directory is also in that directory but htaccess is set to protect it. Can"t wait for the new Git features in cPanel.0 -
is your PROJECT_ROOT also your DOCUMENT_ROOT? The option I was describing would look something like: PROJECT_ROOT = ~ STATAMATIC_PUBLIC_DIR = ~/public_html GIT_WORKING_TREE = ~ DOCUMENT_ROOT = ~/public_html ...if that makes sense. 0 -
is your PROJECT_ROOT also your DOCUMENT_ROOT? The option I was describing would look something like: PROJECT_ROOT = ~ STATAMATIC_PUBLIC_DIR = ~/public_html GIT_WORKING_TREE = ~ DOCUMENT_ROOT = ~/public_html ...if that makes sense.
At the moment I have it like this...Everything is in the document root ~/public_html. Is there a better way? public_html (document root) |--local |--assets |--index.php |--.htaccess |--site |--statamic |--please |--.gitignore0 -
is your PROJECT_ROOT also your DOCUMENT_ROOT? The option I was describing would look something like: PROJECT_ROOT = ~ STATAMATIC_PUBLIC_DIR = ~/public_html GIT_WORKING_TREE = ~ DOCUMENT_ROOT = ~/public_html ...if that makes sense.
This page explains it better: Installing Statamic - Statamic 2 Docs0 -
is your PROJECT_ROOT also your DOCUMENT_ROOT? The option I was describing would look something like: PROJECT_ROOT = ~ STATAMATIC_PUBLIC_DIR = ~/public_html GIT_WORKING_TREE = ~ DOCUMENT_ROOT = ~/public_html ...if that makes sense.
A bare repo works but you can"t commit or pull from it0 -
In an ideal world, your domain.com would be an addon domain, not the primary domain you started the account with. Then the document root location would be manageable from the Addon Domains feature. I realize that's not the most helpful thing in the world, but that's the migration-safe upgrade-safe canonical way to do it. I apologize that we don't make that clear in our communication. (WILL FIX) As an aside, we are currently working on the
0 -
Your link led me to Installing and running above webroot - Knowledge Base - Statamic 2 Docs and that's kinda more of what I was talking about. HOWEVER it sounds like you're good to go with the set up you've gotten to so no need to change it. 0 -
wouldn't the entire contents of the user folders get downloaded on each PULL?
No. Only the things checked into the git repository would come down when you perform a git-pull from another machine.Would I need to add all those extra directories to my .gitignore?
well yes. So it's mildly complicated but basically you'll want to list any paths you don't want git to care about in the .gitignore so that changes in those areas aren't reported as unstaged. I'm not sure what Statamatic's recommendations are for a .gitignore but it's pretty typical for tools like Statamatic to publish a good starting example .gitignore. If Statamatic is rendering content into the $PROJECT_ROOT/public folder, then I bet it would need to be listed in your .gitignore...but, again, you're more of a Statamatic expert than I.0 -
No. Only the things checked into the git repository would come down when you perform a git-pull from another machine. well yes. So it's mildly complicated but basically you'll want to list any paths you don't want git to care about in the .gitignore so that changes in those areas aren't reported as unstaged. I'm not sure what Statamatic's recommendations are for a .gitignore but it's pretty typical for tools like Statamatic to publish a good starting example .gitignore. If Statamatic is rendering content into the $PROJECT_ROOT/public folder, then I bet it would need to be listed in your .gitignore...but, again, you're more of a Statamatic expert than I.
So I need to install a website with Git and some of the site will be above the docroot and some in public_html folder. Can I do this with the new beta version v72? If so can I get access to the beta? I am using latest stable release.0 -
I am looking to set up the site like this if possible with Git. Is this how new v72 version works? I want some files above docroot after all. Trying to do this Installing and running above webroot - Knowledge Base - Statamic 2 Docs public_html |--assets |--index.php |--.htaccess site statamic please .gitignore I could PUSH to the ~/ right now, but I would need to add all the other cPanel folders to my .gitignore like access-logs, mail, etc, logs so I can perform commits correct? Is this best way? 0 -
I ended up making a git repo right in the ~/ and then I could have some files above webroot. I then excluded all the cPanel folders and files from my repo like this: .gitignore file .DS_Store .env node_modules/ installer.php # cPanel /.cpanel/ /.cphorde/ /.htpasswds/ /.ssh/ /.trash/ access-logs /etc/ /logs/ /mail/ /perl5/ /public_ftp/ /public_html/error_log /ssl/ /tmp/ www /.bash_history /.bash_logout /.bash_profile /.bashrc /.contactemail /.gitconfig /.lastlogin /.viminfo /.zshrc
So far all seems to be working well. I think I could also do it the reverse way only "include" the folders I want correct? Less typing probably this way, but I have not tested it./* !/assets !/statamic
0
Please sign in to leave a comment.
Comments
22 comments