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.

Is it possible to allow users to upload server-side scripts to server?

Discussion in 'cPanel Developers' started by ahk, Aug 17, 2012.

  1. ahk

    ahk Registered

    Joined:
    Aug 17, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi all,

    First of all i am new to cpanel and whm, so if i write something wrong please correct me

    Simply I want to let users to upload their php-mysql projects to my server and publish them. But as you can guess there are many things i have to do about security. First of all i have to limit the projects to only work under the project folder and connect only the databases owned by the project owner. These are major requirements and there should be more things i have to do. The problem is that i do not have any idea about how to build such a system with php.

    Here is the scenario:

    - User will signup to my website: mydomain.com/signup (I think user count will be about a few thousands, i hope so : )
    - I will create a user with cpanel or whm api who has only ftp access to folder: public_html/users/USERNAME So he can upload his php-mysql projects under 'projects' folder. Is this possible with cpanel or whm api?
    - I have to let the user to create databases for his projects and manage them via phpMyAdmin. So user must have cpanel/whm access?
    - Projects can be accessed via: mydomain.com/username/projects/sample-php-mysql-project

    URL format and folder names are only samples to help me explain my problem. If there is a better format/solution please let me know.

    For a while i am thinking about this but i am not sure if it is possible or not. If it is possible then what kind of hosting package i must buy? Will managed VPS be enough? I am thinking about HostGator's level 3 VPS: /http://www.hostgator.com/vps-hosting/

    If i missed something or you need more info please let me know

    Any help would be greatly appreciated.
    Thank you
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    These users will need to have cPanel access for this specific component:

    To create a database requires cPanel access. They cannot be created in phpMyAdmin and function properly with cPanel, since they don't then map to /var/cpanel/databases area for users and databases.
     
  3. ahk

    ahk Registered

    Joined:
    Aug 17, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok i understand, isn't it possible to get database name from user and create one for him via cpanel api? so he can manage it via phpMyAdmin.

    Thanks for your help
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    It is possible to push something via the cPanel API to create the database for him. You probably want to post in the developer's section of the forum if you are wanting to use the API for these functions. Have you reviewed the API at this point?

    I would be happy to move this thread over to that section (developer's area) if you'd like.
     
  5. ahk

    ahk Registered

    Joined:
    Aug 17, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Please move it to developer area.
    I haven't checked API yet, i just wonder if such a system is possible. If yes a link to related API functions or tutorials will be very helpful.
     
  6. 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
    Unless you are going to give each user a cPanel account, a VPS sounds like overkill for this.
    You sound like you are better off giving each user a cPanel account, that way your have finer control over those users and most of the coding is done for you.
    If you chose to do it that way you can create a signup page with a backend database that stores information on users.
    You can use the XMLAPI to create/manage/delete users.
    XML and JSON APIs
     
  7. Humza Bajwa

    Humza Bajwa Registered

    Joined:
    Aug 19, 2012
    Messages:
    0
    Likes Received:
    0
    Trophy Points:
    0
    cPanel Access Level:
    Website Owner
    I vaguely remember something like this happening before. There was an issue with having to create a cpanel account for every single user who wanted to do so (permissions were an issue as well). I feel like it would be easier for them to submit the script and have someone (assign a moderator) to upload the scripts to the server.

    ---
    Humza Bajwa
     
  8. ahk

    ahk Registered

    Joined:
    Aug 17, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    After some research and advices from forum users i think such a system can be done. Here is what i have learned, if you find something wrong please correct me:

    - I will create a cPanel account with minimum resources and permissions for each user: /json-api/createacct. I dont want users to login cpanel, i will add an ftp account which can access to only public_html so user can upload files via ftp. Before creating account i should check plan and package variables. I am reading api docs, also any advice about options will be appreciated.
    - I will provide an interface which user can manage his databases.
    - In such a system still do you suggest moderation for files? None can access other users and system resources, isn't it?
    When creating cPanel accounts what should i use for domain? Because i don't need this and i want users can access projects like this: mydomain.com/username/projects/sample-php-mysql-project can this be possible?
     
  9. 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
    This makes sense. You can add the FTP user with this api call: Ftp Module Documentation

    I'd remove all the options you can from the plan/package as you can always add additional functionality if users require it.
    The users will be limited to file access by linux file permissions. By default, each user will only have access to their /home/$user/ directory along with any files on the system with global read/write/execute permissions
    Use username.mydomain.com as the domain in cPanel rather than domain.com/username. Since they are seperate domains, you could also add a redirect for each user from mydomain.com/username/* to username.mydomain.com/*
     
Loading...

Share This Page