Go Back   HostGator Peer Support Forums > Public Forums > Suggestions

Notices

Reply
 
Thread Tools
  #51  
Old 05-06-2007, 01:47 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,067
Default Re: HostGator not support PHP.ini?

Quote:
Originally Posted by D.Alexander View Post
Hello there

can i with php.ini increase upload_max_filesize?

and what i must type in php.ini file?


thank you
upload_max_filesize = 20M;
post_max_size = 20M;

...but you can check that yourself by putting it in php.ini and looking at phpinfo();
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #52  
Old 04-25-2008, 08:49 PM
rabeles rabeles is offline
Hatchling Croc
 
Join Date: Mar 2008
Posts: 2
Default Re: HostGator not support PHP.ini?

This script creates a private, modified copy of php.ini and installs symlinks to it in each directory in your website directory tree. I wrote it based on a script quoted earlier in this thread to automate an otherwise tedious process. I run it periodically with cron to keep my modified php.ini up to date with any host changes.

It will create a modified php.ini in your home directory named local_php.ini from the system copy at /usr/local/lib/php.ini. It will then place a symbolic link named php.ini in each directory in your website pointing to your local_php.ini. Note that this script will unlink any php.ini already in a directory it visits, so be careful. Also, be sure to consult phpinfo() for the location of your host's php.ini.

PHP Code:
<?php
// Create custom php.ini and install in entire website's directory tree.

// Fill the $overrides array with php parameters to be overridden.
$overrides[] = "register_globals = Off";

// File and path names for your host and website.
$host_php_ini  "/usr/local/lib/php.ini";     // your host's php.ini file (see phpinfo())
$local_php_ini "/home/*USER*/local_php.ini";  // your modified php.ini will go here
$website_root  "/home/*USER*/public_html";    // your website's root

// Generate php.ini with overrides appended, write it, and change mode to 0600 for security.
$php_ini_text file_get_contents($host_php_ini)
    or exit(
"Error: Unable to read file $host_php_ini");
$php_ini_text .= "\n; >>>Start Parmameters Overridden by php_override.php<<<\n";
foreach (
$overrides as $override)
    
$php_ini_text .= $override "\n";
$php_ini_text .= "; >>>End Parameters Overridden by php_override.php<<<\n";
file_put_contents($local_php_ini$php_ini_text)
    or exit(
"Error: Unable to write overridden file $local_php_ini");
chmod($local_php_ini0600)
    or exit(
"Error: Unable to chmod file $local_php_ini");

// Walk website directory tree, inserting symbolic links to modified php.ini file.
$nodes = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($website_root),
                                       
RecursiveIteratorIterator::SELF_FIRST);
foreach (
$nodes as $node) {
    if (
$node->isDir()) {
        
$linkpath $node->getPathname() . "/php.ini";
        
unlink($linkpath);
        if (!
symlink($local_php_ini$linkpath))
            echo 
"Error: Unable to create symbolic link $linkpath to $local_php_ini\n";
        else
            echo 
"Linked: $linkpath to $local_php_ini\n";
    }
}

// RecursiveIteratorIterator::SELF_FIRST does not deliver. Do website root here.
$node = new SplFileInfo($website_root);
if (
$node->isDir()) {
    
$linkpath $node->getPathname() . "/php.ini";
    
unlink($linkpath);
    if (!
symlink($local_php_ini$linkpath))
        echo 
"Error: Unable to create symbolic link $linkpath to $local_php_ini\n";
    else
        echo 
"Linked: $linkpath to $local_php_ini\n";
}
?>
Reply With Quote
  #53  
Old 05-19-2008, 04:42 PM
debrag debrag is offline
Hatchling Croc
 
Join Date: Nov 2007
Posts: 19
Default Re: HostGator not support PHP.ini?

my .htaccess file only contains:

Quote:
# BEGIN WordPress

# END WordPress
by adding 'php_flag register_globals off' my site is un usable.

I have some htaccess.txt files that seem to be joomla files.
Reply With Quote
  #54  
Old 08-25-2008, 10:47 PM
Prepress Forums Prepress Forums is offline
Hatchling Croc
 
Join Date: Jan 2008
Posts: 8
Default Re: HostGator not support PHP.ini?

php_value max_execution_time 300
php_value memory_limit 8M
php_value post_max_size 20M
php_value upload_max_filesize 20M

Putting these in the .htaccess, will that work at the sub folder level or must that be at the web root of the domain?
Reply With Quote
  #55  
Old 08-25-2008, 11:04 PM
striddy striddy is offline
Emperor Croc
 
Join Date: Mar 2008
Location: /home/australia/earth
Posts: 2,664
Default Re: HostGator not support PHP.ini?

Quote:
Originally Posted by Prepress Forums View Post
php_value max_execution_time 300
php_value memory_limit 8M
php_value post_max_size 20M
php_value upload_max_filesize 20M

Putting these in the .htaccess, will that work at the sub folder level or must that be at the web root of the domain?
You mean php.ini not .htaccess. Php.ini's need to be in each subdirectory where you want the changes.

Before you do anything, create yourself a phpInfo page so you know what your settings are.

Create a page with the following content, then upload to your website and view it in your browser. Then search for the parameters you listed above to see what the settings are.

Code:
<?php
phpinfo ();
?>
__________________
- David

Folding@Home Stats :
Reply With Quote
  #56  
Old 01-01-2009, 06:32 PM
whitespace whitespace is offline
Hatchling Croc
 
Join Date: Dec 2008
Posts: 16
Default Re: HostGator not support PHP.ini?

I also modified the script a bit to include the scenario where someone wants to erase all the symbolic links.

I did the symbolic way but didnt like all those symbolic links in the subfolders. So I needed a way to delete all the symbolic links. You can see the code on my blog page here.

I also wrote another script to copy php.ini to all the main domain folders (not sub folders).

Hope this helps someone.

Scott -
bargainscent.com - online bargains
drinkgenius.com - drink recipes
Reply With Quote
  #57  
Old 01-01-2009, 09:39 PM
gwyneth's Avatar
gwyneth gwyneth is offline
Veteran Croc
 
Join Date: Sep 2006
Location: Apostle Islands, Lk Superior
Posts: 5,926
Default Re: HostGator not support PHP.ini?

whitespace, can you please place those unrelated links in your signature rather than the body of the message? Thanks.
Reply With Quote
  #58  
Old 01-04-2009, 02:32 AM
GatorEricS's Avatar
GatorEricS GatorEricS is offline
HostGator Staff
 
Join Date: Dec 2007
Location: Houston
Posts: 604
Arrow Re: HostGator not support PHP.ini?

Perhaps this will help, as well:

If you have SSH access (which can be requested), you can use the following command from shell:
Code:
phpiniuser='USERNAME' && cat /usr/local/lib/php.ini | replace 'register_globals = On' 'register_globals = Off' > /home/$phpiniuser/php.ini && chown $phpiniuser. /home/$phpiniuser/php.ini
Simply change the word USERNAME to be your account username (i.e. phpiniuser='gwyneth' (if I may borrow her as example)). This will automatically copy the server's php.ini file, as well as change register_globals to off, and place it in your home directory, owned by you.

You can then add the following code to your .htaccess file:
Code:
<IfModule mod_suphp.c>
 suPHP_ConfigPath /home/USERNAME
 <Files php.ini>
   order allow,deny
   deny from all
 </Files>
</IfModule>
Again, where USERNAME is your username (aka: suPHP_ConfigPath /home/gwyneth).

Whenever someone requests a custom php.ini file through a support ticket, I have a hotcommand that fires a similar line that copies the file, chowns it, and auto-creates a .htaccess file in the /home/username. Since .htaccess interits by parent, then anything in /home/username/.htaccess will apply to all directories, thus the php.ini will apply. The FULL line I use to do all of this is:
Code:
phpiniuser='USERNAME' && cat /usr/local/lib/php.ini | replace 'register_globals = On' 'register_globals = Off' > /home/$phpiniuser/php.ini && chown $phpiniuser. /home/$phpiniuser/php.ini && echo "######################################################" >> /home/$phpiniuser/.htaccess && echo "# Custom php.ini setup added by support, do not edit #" >> /home/$phpiniuser/.htaccess && echo "######################################################" >> /home/$phpiniuser/.htaccess && echo "<IfModule mod_suphp.c>" >> /home/$phpiniuser/.htaccess && echo " suPHP_ConfigPath /home/$phpiniuser" >> /home/$phpiniuser/.htaccess && echo " <Files php.ini>" >> /home/$phpiniuser/.htaccess && echo "   order allow,deny" >> /home/$phpiniuser/.htaccess && echo "   deny from all" >> /home/$phpiniuser/.htaccess && echo " </Files>" >> /home/$phpiniuser/.htaccess && echo "</IfModule>" >> /home/$phpiniuser/.htaccess && echo "### RESUME EDITING BELOW #############################" >> /home/$phpiniuser/.htaccess && chown $phpiniuser. /home/$phpiniuser/.htaccess
Hope this helps you folks. Dedi users will find the last line especially useful, as it's an all-in-one command for deployment (can only be applied to another account if you are the root user).

Regards,
-Eric
__________________
--
Hostgator.com, LLC
Linux Systems Administrator
Gator, mushroom, snake?
Reply With Quote
  #59  
Old 01-04-2009, 04:22 AM
striddy striddy is offline
Emperor Croc
 
Join Date: Mar 2008
Location: /home/australia/earth
Posts: 2,664
Default Re: HostGator not support PHP.ini?

Quote:
Originally Posted by GatorEricS View Post
Hope this helps you folks.
Very helpful. Thanks Eric.
__________________
- David

Folding@Home Stats :
Reply With Quote
  #60  
Old 11-05-2009, 11:45 AM
digitaltoast digitaltoast is offline
Baby Croc
 
Join Date: May 2008
Posts: 79
Default Re: HostGator not support PHP.ini?

Quote:
Originally Posted by GatorEricS View Post
Perhaps this will help, as well:
Ah, so are you saying that I now don't need to use the script I currently use, which I found here ages ago, which makes gazzilions of symbolic links in all the subdirectories to the edited copy of php.ini which is in the root folder?

So I'm guessing that .htaccess will now take care of the subdirectories?
It's just that I remember before that php.ini was only acting on the folder it was in. This looks like a much better solution.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 06:22 PM.

 
Forum SEO by Zoints