Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Problem getting site to work with Git repo

Discussion in 'General Discussion' started by bgarrant, Jan 17, 2018.

Thread Status:
Not open for further replies.
  1. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    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.
     
  2. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Been looking all morning and kind find an answer. Can anyone provide any advice?
     
  3. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,580
    Likes Received:
    439
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    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
     
  5. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
  6. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    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
     
    #6 bgarrant, Jan 17, 2018
    Last edited by a moderator: Jan 17, 2018
  7. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    241
    Likes Received:
    55
    Trophy Points:
    103
    Location:
    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?
     
    Infopro likes this.
  8. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    241
    Likes Received:
    55
    Trophy Points:
    103
    Location:
    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.
     
  9. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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.
     
  10. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    241
    Likes Received:
    55
    Trophy Points:
    103
    Location:
    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.
     
  11. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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
     
  12. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    This page explains it better: Installing Statamic - Statamic 2 Docs
     
  13. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    A bare repo works but you can’t commit or pull from it
     
  14. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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.
     
  15. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    241
    Likes Received:
    55
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
  16. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    I was trying to install above docroot, but the creator of the CMS informed me that the have a rock solid .htaccess and it is vulnerability tested. Should be fine as it is for now. Thanks for all your help.
     
  17. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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?
     
  18. cPanelAdamF

    cPanelAdamF cPanel Product Owner
    Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    241
    Likes Received:
    55
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    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.
     
  19. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    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.
     
  20. bgarrant

    bgarrant Well-Known Member

    Joined:
    Jun 27, 2012
    Messages:
    68
    Likes Received:
    9
    Trophy Points:
    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?
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice