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.

WHM hostname public_html location

Discussion in 'General Discussion' started by Devgineer, Dec 19, 2012.

  1. Devgineer

    Devgineer Registered

    Joined:
    Dec 19, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    I have been using CPanel since 2009 and quickly became a WHM reseller. I am currently running my own server and am now setting up two more.

    Anyways, I would like to know how to add an index.html and .htaccess file to the hostname. When you setup WHM it asks for a hostname and this gets added to Home » IP Functions » Show IP Address Usage and also Home »
    IP Functions » Show or Delete Current IP Addresses.

    I was able to setup a new user on my first CPanel account with their IP address set to the main address somehow. This allowed me to create a splashpage for the hostname.

    Does anybody know how to either
    A) create a new user and assign that user the server hostname as an addon domain or main domain?
    B) location of directory where I can put an index.html file with a .htaccess through ssh sftp?

    thank you.
     
  2. Devgineer

    Devgineer Registered

    Joined:
    Dec 19, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    So I ran find -name httpd.conf and looked at the virtual host file in:
    /usr/local/apache/conf/httpd.conf

    I then navigated to:
    /usr/local/apache/htdocs/

    I added a .htaccess file but it has no effect. I can edit index.html and see those changes work though.

    I'm still puzzled over how I got the reseller account associated with the main IP on my first server though. Any ideas?
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    The hostname of the server should not be added to an account. That would cause several conflicts with the Apache and cPanel configuration. You can modify the default website template at:

    "WHM » Account Functions » Web Template Editor"

    To clarify, do you want a specific website to load when you access the main shared IP address of the server?

    Thank you.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,470
    Likes Received:
    197
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You can use the domain name of the hostname for an account, I've been doing it for years. I create the first account using the same domain name used in the hostname.

    Setup a server with a new domain and create the hostname: server1.mydomain.com
    Create your Reseller account.
    Create your Packages and Features.
    Create your first account using mydomain.com

    Advanced: If you've already created some other account(s) first, you might be able to rearrange your virtual hosts in httpd.conf and then distill it to save the changes properly. I did this once years ago pre EA3 days, and have since opted to create that first account for me instead, easier that way. mydomain.com in the example above needs to be first virtual host.

    I hope my post isn't confusing the issue here.
     
  5. Devgineer

    Devgineer Registered

    Joined:
    Dec 19, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    @cPanelMichael, I have to respectfully disagree with your assesment. I see no issue with using the hostname of the server in 1 account. I can see where it would create conflicts if used in multiple accounts however. Also, I need to be able to drop php and .htaccess in the root of my server so a simple template would not work.

    @Infopro. Thanks for your suggestions. I think the first approach will work great with my other new server. I have already setup a few accounts and was leaning towards the "Advanced" approach based on the documentation but found an easier workaround that appears to stick.

    1) create a new account with bogus hostname (i used... host.home)
    2) SSH into server and change directory e.g.
    cd /var/cpanel/userdata/username
    3) edit the file for the bogus domain e.g.
    nano host.home
    vi host.home
    4) change the IP to main IP address which can be found under WHM ->IP Functions -> Show IP Address Usage. The main IP is the one with your hostname next to it. Take note of that IP and put it on the line that says:
    ip: x.x.x.x
    5) save file and exit
    6) type /scripts/rebuildhttpdconf [enter]
    7) type service httpd restart

    Presto! now visting the hostname will display whatever is in the new accounts home directory. You can also use the CPanel functions to set directory listings, image protect, etc. Hope this helps someone out there and if you haven't setup your server yet, follow the directions posted by Infopro

    @
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    671
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I think it's important to clarify what I mean by the "hostname" of the server. By hostname, I am referring to the name used in:

    "WHM » Networking Setup » Change Hostname"

    It's what you see when you run the following command:

    # hostname

    This is not the same thing as the domain name associated with the hostname, which is what InfoPro is referring to. For example, if your hostname is "123.example.com" then it's perfectly acceptable to create a new account with "example.com". However, it would not be acceptable to create a new account with "123.example.com". Using the hostname of the server for a new account should result in the following error message when running /scripts/updateuserdomains:

    Code:
    root@server [~]# /scripts/updateuserdomains
    == WORKAROUND ENABLED ==
    Serious Problem -- This should never happen!!
    The hostname (123.example.com) is owned by the user example
    == WORKAROUND ENABLED ==
    You will likely encounter problems accessing email, FTP accounts, or adding parked/addon domain names. It could also prevent you from rebuilding the Apache configuration file. While you are welcome to use your custom setup, it's not recommended.

    Thank you.
     
  7. Devgineer

    Devgineer Registered

    Joined:
    Dec 19, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I'm not sure how the first server got setup with that custom configuration but I liked it and never had any issues.

    I think the hostname should match the dns entry and then have ptr (reverse dns) setup to match also. This is especially true for proper configuration of email.

    Lets say I setup my hostname as server1.domain.com, and someone wants to access server1.domain.com over http. I may want to automatically redirect them to CPanel, Webmail, give an access denied message, etc.

    Apparently the default htdocs directory does not allow use of php code and .htacees. In fact they both appear to give a 500 error messaage.

    So creating an account and manually assigning it the servers main IP address allows me to use the accounts public_html directory to serve up any content I see fit. I have not experienced any problems in over a year and did not remember how I got this to work

    Thank you for your reply. I appreciate the feed back and support offered from this product.
     
Loading...

Share This Page