SOLVED Problem getting site to work with Git repo

Status
Not open for further replies.

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
I know how to do all that, but how do I get the document root to point to the new "~/project/example" folder without breaking other cPanel featured like AutoSSL? I am trying to serve up a webpage from the repo. I would upload it direct to "public_html" but I need some files above webfoot like this:

local
public_html
|-- assets
|-- index.php
|-- .htaccess
site
statamic
please
.gitignore
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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
 
Last edited by a moderator:

cPanelAdamF

cPanel Product Owner
Staff member
Mar 21, 2013
251
64
153
Houston TX
cPanel Access Level
DataCenter Provider
Twitter
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?
 
  • Like
Reactions: Infopro

cPanelAdamF

cPanel Product Owner
Staff member
Mar 21, 2013
251
64
153
Houston TX
cPanel Access Level
DataCenter Provider
Twitter
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.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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.
 

cPanelAdamF

cPanel Product Owner
Staff member
Mar 21, 2013
251
64
153
Houston TX
cPanel Access Level
DataCenter Provider
Twitter
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.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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
|--.gitignore
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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 it
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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?
Statamic can be installed in the docroot or above it as they have an excellent .htaccess script for security. I decided to keep it simple just to install in docroot for now. In future once you have Git integration maybe there will be more options. Installing the core above docroot just is an additional layer of security.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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.
If I did want to install above docroot, wouldn't the entire contents of the user folders get downloaded on each PULL? Like the .htpasswds, .ssh, /trash, access-logs, etc.? If I make it my working directory and place the publicly needed files in /public_html, what happens when I PULL the site? Would I need to add all those extra directories to my .gitignore? How do you suggest?

This is why the original thought was to make a /project folder with a new public_html folder in in and looks to change the document root like this.

project
|--local
|--public (need to make this the document root)
|--|-- assets
|--|-- index.php
|--|-- .htaccess
|--site
|--statamic
|--please
|--.gitignore
public_html (existing folder)

How is best way to do it this way?
 

cPanelAdamF

cPanel Product Owner
Staff member
Mar 21, 2013
251
64
153
Houston TX
cPanel Access Level
DataCenter Provider
Twitter
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.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
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?
 
Status
Not open for further replies.