The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Document Root - Edit in bulk?

Discussion in 'cPanel Developers' started by forumfish, Feb 7, 2012.

  1. forumfish

    forumfish Member

    Joined:
    Nov 13, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello, I've had this question before (https://forums.cpanel.net/f5/possible-have-domain-point-1-directory-cpanel-another-243291.html) and have learned to make the edits manually for what I needed.

    I am however running into an issue now where the /var/cpanel/userdata/USER/DOMAIN.com is changing the user: field on previously modified files.

    I.e.

    documentroot: /home/CORE-DIR/public_html
    user: CORE-DIR <--- changes back to OWNER of that cpanel account

    My issue is now when I run the httpd restart it will crash those previously working sites due to user not having access to CORE-DIR.

    My Question:

    Is there a simple batch file I can write that will scan /var/cpanel/userdata/* for all files that contain "documentroot: /home/CORE-DIR/public_html" and change the "user:" from OWNER -> CORE-DIR.

    Thank you.

    NOTE: I am using SSH to make all changes to files BUT am using WHM to create the accounts, which could be causing the conflict I am having. If there is an easier way to create cpanel accounts inside SSH that will not change previously modified "user:" fields, please let me know.
     
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Try running /scripts/rebuildhttpdconf after your edits. This should rebuild httpd.conf from the userdata (I believe, haven't tried it at the moment).
     
  3. charsleysa

    charsleysa Active Member

    Joined:
    Jul 18, 2011
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Palmerston North, New Zealand
    cPanel Access Level:
    Root Administrator
    You can create cPanel through SSH by running the wwwacct script in /scripts
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    How does that help the OP change the document root though?
     
  5. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator

    I believe that charsleysa was responding in reference to this original item:

    Unfortunately, the reality is that the original post is unclear. If you've already edited /var/cpanel/userdata/$user, that means that an account has been previously created so creating one will not work as it will error on duplicate information. If you've created a set of /var/cpanel/userdata/$user files before an account is created, that will not work as well.

    At current, cPanel is designed to use $home/public_html for the document root on all new accounts. You can change the value of $home in WHM by setting the home directory prefix but there's no official method to set the document root on a per account basis.

    This does sound like a valuable feature and I'd recommend forumfish to submit a feature request for this feature so that in the future, they do not have to attempt a workaround.
     
    #5 KostonConsulting, Feb 9, 2012
    Last edited: Feb 9, 2012
  6. forumfish

    forumfish Member

    Joined:
    Nov 13, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you for your responses.

    Koston is current. The accounts were created already, I edited the document root inside /var/cpanel/userdata/$user to reflect $home of Reseller account.

    My goal with this entire project was to create individual cpanel accounts for users to modify their own email information, but keep the websites created for them in the root directory of the reseller account.

    I will see about putting in a feature request.
     
  7. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    Have you used the webmail interface on port 2096? When going to https://domain.com:2096, users can manage their individual email account with the following features:

    Read Webmail
    Change Password
    Forward Mail
    Create/Edit/Delete Auto-Responders
    Setup Mail Client
    BoxTrapper
    Email Filtering
    Email Trace
     
  8. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    You're going to run into a whole host of problems with trying to set a DocumentRoot for a cPanel account to a location within a different cPanel user's account. First and foremost, there's the simple fact of user/group ownership and filesystem permissions on all of the content (which is unrelated to cPanel and simply a native Linux OS design concern for you to consider). Beyond that, cPanel & WHM is not designed with "cross-linking" accounts (for lack of a better term) in mind and you'll likely run into a plethora of problems stemming back to filesystem ownership issues. I would strongly advise against pursuing such an unsupported setup.

    Your best bet is to utilize "Addon Domains" within the primary cPanel user (so that everything remains under the same cPanel user) and then using the custom FTP account to allow the user to upload/manage their site content. Of course, though, there isn't a means to give them limited access to Email creation/Database creation/etc. There isn't a current cPanel & WHM feature that satisfies that portion of your needs.

    But, there is a feature request already submit that would cover this. I'd advise you post your support for it in its thread:
    http://forums.cpanel.net/f145/multiple-cpanel-logins-cpanel-subusers-case-44353-a-77145.html

    If you're a knowledgeable programmer or are willing to hire one, it would always be possible for you to take advantage of the cPanel & WHM API to create a simple web interface that allowed your clients to manage their email creation/deletion. It all depends on if this is something you're looking for *immediately* or if you're willing to wait on the feature request.
     
Loading...

Share This Page