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.

Dedicated Php.ini File Per Account

Discussion in 'General Discussion' started by logikstudios, Nov 26, 2006.

  1. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    Hey. A Person who i am hosting a site for has asked me enable safe mode on his account. If i did that everyone else account would suffer. There is a way to set up a dedicated php.ini file for each account. How do i do this.

    Thanks,
    Nathaniel
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    PHP.INI options can also (usually) be configured within the virtualhost block for a website. Check the PHP Manual for more specifics, but I think enabling safe mode is something like:

    php_admin_flag safe_mode On
     
  3. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    Add this

    Code:
    php_admin_flag safe_mode On
    
    in httpd.conf file, but online inside the <VirtualHost></VirtualHost> for that domain only.
     
  4. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    does that go in the php.ini file.

    Sorry i am really new to this kind of thing.
     
  5. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    No, it doesn't. You know what, since you don't know what that is the best thing to do is leave it alone, but i'll try to teach the best way possible.

    First, you are going to SSH the server as root, if you know know what I just said or if you don't have root access to the server then forget about it.

    First left make a backup file, type this:
    Code:
    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.my_backup
    
    in the server type this:

    Code:
    vi /usr/local/apache/conf/httpd.conf
    
    ok, now search for the domain that needs safemode on, you do a search by typing / and then typing what you what to search. Pay attention to the lower left corner, that's where you will see what you are searching for, it's going to look alot like this:

    Code:
    /domain.com
    
    after typeing that press enter.

    Ok, when you find the domain its going to look something like this:

    Code:
    <VirtualHost 111.111.111.111>
    ServerName www.domain.com
    ServerAlias domain.com
    ServerAdmin webmaster@domain.com
    DocumentRoot /home/userdom/public_html
    BytesLog domlogs/domain.com-bytes_log
    User userdom
    Group userdom
    
    <IfModule mod_userdir.c>
      Userdir disabled
      Userdir enabled userdom 
    </IfModule>
    
    <IfModule mod_php5.c>
      php_admin_value open_basedir "/home/userdom:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    
    CustomLog /usr/local/apache/domlogs/domain.com combined
    ScriptAlias /cgi-bin/ /home/userdom/public_html/cgi-bin/
    </VirtualHost>
    
    Ok, using the arrow keys, go right bellow the second </IfModule> and press O

    Now you are going to type:

    Code:
    php_admin_flag safe_mode On
    
    when you are done typing press the escape key and save the file by pressing
    Code:
    :wq
    
    now restart apache

    Code:
    /etc/init.d/httpd restart
    
    and take a look to see if safemod is on for that domain.

    If something goes wrong let's restore the backup that we made:

    Code:
    cat /usr/local/apache/conf/httpd.conf.my_backup > /usr/local/apache/conf/httpd.conf
    
    That's it I think :D
     
  6. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    Hey. I do have root access. I might pay some people in the datecentre to do it. I have done basic file editing and moving files in ssl but i am not comftable in editing the apache settings.
     
  7. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    That's is the best thing you should do, don't touch on files when you are not sure of what you are doing.

    I sugest you give'm the link for this post so they can understand what you need.

    Good luck.
     
  8. HelloAdam

    HelloAdam Well-Known Member

    Joined:
    Nov 6, 2005
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    Hey,

    Can't you just put that in a .htaccess file, that should work?

    From,
    Adam
     
  9. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    No. It depends upon the Options and Overrides allowed.
     
  10. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    This specific option can't be put on the .htaccess file because is only changeable at PHP_INI_SYSTEM level, which means "Entry can be set in php.ini or httpd.conf"

    More info here http://www.php.net/manual/en/ini.php
     
  11. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    Before i had my own server i had a reseller account on webhosting company. What they did is that they had a php folder in every accounts root. What i mean by that is as they can go up. So they see the folder www,mail,public_html etc

    Couldn't you just put a folder called php in the root then put the file in?
     
  12. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    I Think i have found it! http://www.suphp.org/

    I asked my old hosting provider and he said this is what he used.
     
  13. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    Not on servers with CPanel, at least not that I know.
     
Loading...

Share This Page