Solved

Can't change PHP (.ini) post/upload limit

Posted on 2010-11-10
9
914 Views
Last Modified: 2013-12-13
I'm trying to change the post_max_size (32MB) and upload_max_filesize (12MB) on my server, but they keep falling back to defaults (8MB and 2MB respectively).

Here are some details of the scenario:
Server: VPS hosted by GoDaddy (\w 3GB Ram and 1.5TB monthly bandwidth)
OS: CentOS 5.4
Apache: 2.0
PHP: 5.2.10

I have ruled out following obvious causes:
1. Apache is restarted after modifying the php.ini
2. There's only one php.ini on the whole server, so I'm 100% confident I'm working with the correct php.ini (other setting I change take effect perfectly)
3. GoDaddy has confirmed that they don't have any restrictions or caps on the php settings and I'm free to modify them.

Has any one faced this issue before? (On GoDaddy or any other server) or can any one shed some light on the situation?

Thanks In Advance.
0
Comment
Question by:Sudaraka Wijesinghe
9 Comments
 
LVL 16

Accepted Solution

by:
medvedd earned 400 total points
ID: 34102044
Add the lines to  .htaccess file in your root directory:

php_value upload_max_filesize 12M
php_value post_max_size 32M

0
 
LVL 26

Expert Comment

by:jar3817
ID: 34102116
How are you checking the current values? phpinfo()?
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 34104966
Hi,

Please create an info.php file with the following contents.

<?
phpinfo();
?>

Now access the info.php file using browser and check the location of "Loaded configuration File". You need to edit the php.ini file mentioned in the "Loaded configuration File". Also you can check the post_max_size and upload_max_filesize in the info.php. Also it will be helpful if you could take a screen shot of the info.php and attach it here to check this further.
0
 
LVL 18

Author Comment

by:Sudaraka Wijesinghe
ID: 34105239
Thanks every one for their participation.

medvedd's suggestion worked.

Before I close this, I would like to discuss why I was able to set the php configuration from .htaccess but not from the php.ini?
Any ideas?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 13

Expert Comment

by:LinuxGuru
ID: 34105542
PHP can run in the following ways.

    * php run as Apache Module
    * php run as CGI / Fast Cgi
   
php_flag and _php_value can be written in httpd.conf in FastCGI, but not in .htaccess file. if PHP is running as module, you can do anything with .htaccess. So I think your PHP is running as Apache module.
0
 
LVL 18

Author Comment

by:Sudaraka Wijesinghe
ID: 34105668
yes, it is running as Apache module, but that doesn't explain why I couldn't set the configuration values from php.ini? or is it?
0
 
LVL 13

Assisted Solution

by:LinuxGuru
LinuxGuru earned 100 total points
ID: 34105774
Ok, I will explain.

Difference between CGI and apache Module Mode

An Apache module is compiled into the Apache binary, so the PHP interpreter runs in the Apache process, meaning that when Apache spawns a child, each process already contains a binary image of PHP. A CGI is executed as a single process for each request, and must make an exec() or fork() call to the PHP executable, meaning that each request will create a new process of the PHP interpreter. Apache is much more efficient in it's ability to handle requests, and managing resources, making the Apache module slightly faster than the CGI (as well as more stable under load).

CGI Mode on the other hand, is more secure because the server now manages and controls access to the binaries. PHP can now run as your own user rather than the generic Apache user. This means you can put your database passwords in a file readable only by you and your php scripts can still access it! The "Group" and "Other" permissions can now be more restrictive. CGI mode is also claimed to be more flexible in many respects.

If your server is configured to run PHP as an Apache module, then you will have the choice of using either php.ini or Apache .htaccess files, however, if your server runs PHP in CGI mode then you will only have the choice of using php.ini files locally to change settings, as Apache is no longer in complete control of PHP.

Hope everything is clear now. :)
0
 
LVL 5

Expert Comment

by:SimonDard
ID: 34110259
You can check phpinfo() to make sure that the php.ini you mention is also the one that gets loaded/parsed.

Other than that, a stray .htaccess, safe mode or module for added security (e.g. Suhosin) could be a cause.
0
 
LVL 18

Author Closing Comment

by:Sudaraka Wijesinghe
ID: 34127381
Thanks again to everyone for their participation.

My problem was solved using medvedd's suggestion.
And award some points to testez for his informative posts and eagerness to help.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now