Edit php or add htaccess file?

Edit php or add htaccess file?

by Melissa Benson -
Number of replies: 12
I want to edit the php.ini - sessions.gc_maxlifetime and post_max_size. I have sudo access but when i vi into the php.ini it says read only.

I think you can either edit the php.ini or create an htaccess file? The server our Moodle is on is ubuntu 8.04 and it's only for Moodle. Nothing else is on it or will be on it so editing the php.ini would be okay i nthe respect.

However, would adding an htaccess work as well, be easier? If so, where does that file go?

Thanks!
Average of ratings: -
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Marc Grober -
1 of the half a dozen docs addressing php.ini and htaccess, which have you reviewed already
2 having sudo access doesn't tell us how you used sudo or how sudo is configured...
3 what the perms on the php.ini file you want to edit and what rights do you have when you sudo?
4 did your editor prevent you from overwriting with :w!
5 have you tried to change perms before editing (not forgetting replace when done) and if so with what results
6 are you SA on this machine and if not did you pose your question to the SA, and if you are have you read the docs about hosting?
In reply to Marc Grober

Re: Edit php or add htaccess file?

by Melissa Benson -
I have viewed the session handling docs, but I need to go view the php.ini and htaccess docs I didn't know there was specific docs on this smile

For whatever reason I thought it was read only, it's not. I AM able to edit the php.ini. I actually did edit it..but I edited the post_max_size and upload_max_filesize which is another issue we need to fix. I was able to save the file. However I do not think it worked.. I wonder if I have to to restart apache?

I was given sudo rights by this command: sudo adduser <username> admin . I am not even in the networking area but I know more about Linux (which is the only Linux server our district has and it's for Moodle) than the networking people... and that is not much.

I will have to read up on the htaccess and php.ini docs. For now, do you know if anything needs to be restarted after editing the php.ini? Thanks for your help.
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Greg Lund-Chaix -
Hi Melissa,

You're getting close, but you do need to reload apache. A graceful reload should be sufficient - "sudo /etc/init.d/apache2 reload" or "sudo apache2ctl reload" depending on your system config.
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Marc Grober -
No....... contrary to popular conception you only need to restart apache if you are running php as mod_php. If you run it as CGI than you don;t have to worry about restarting apache at all.... if the change you made to php.ini does not show up then you may have edited the wrong instance of the file/edited a file where it won't get sourced, or you are running mod_php, in which case you can do a restart of your daemon either through whatever admin tools you may be using or via the command line....

You should probably get acquainted with the appropriate management tools for your system, yast, webmin, etc and should read the man pages on sudo and its conf file if you are going to be the default SA.... you are in for a rather steep learning curve as it is one thing to throw something up, another to properly administer it..... I would certainly want to make sure your system is fully locked down before putting any student data in your moodle.....

In reply to Marc Grober

Re: Edit php or add htaccess file?

by Melissa Benson -
Thanks for the help so far, after restarting apache I did not see any changes but I think I may have to edit the Limit Body something?

Anyways, same issue but different situation:

I am working with a Moodle install on a off-site host using Windows 2008. I am using the htaccess option. I copied it from Moodle and edited it. It does not seem to be reading the htaccess or seeing the change.

After changing the upload size will I see the new limit i put in, in the drop down menus of the site policies and the course settings? Also, when you upload something does that upload size it states change to the upload size you put it? Basically, how do I know it worked besides actually uploading something to test it. Thanks.
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Melissa Benson -
i just got a response back from support saying:

"Due to the limitations with htaccess in a windows environment and will not have the capabilities of disabling or configuring the upload limitations of the Moodle CMS.

There may be an additional module that Moodle uses that may assist in the upload process.

Editing the php.ini file will not be an option in a shared web hosting environment."


Um, there has to be a way to change the upload limit on a Windows OS....right??
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> Um, there has to be a way to change the upload limit on a Windows OS....right??

Oh ja! Provided that the administrators are competent and willing. ;)
In reply to Visvanath Ratnaweera

Re: Edit php or add htaccess file?

by Melissa Benson -
I'm working with support on that one ha.

I'm still having issues with my ubuntu server and the max upload. I changed the php and I saw no change. I used the htaccess and I see no change. After I change the size either way, should that new upload limit show when uploading the file and in the course settings in the drop down menu? Ugh this is getting annoying.
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The first place to check after changing your configuration would be the php info page ( Administration > Server > PHP Info ). If the changes do not reflect there then it will certainly not work any where in Moodle!
In reply to Jon Witts

Re: Edit php or add htaccess file?

by Melissa Benson -
okay, an update!


I changed the apache config (http://docs.moodle.org/en/File_upload_size#Modifying_the_apache_config_file)

It then worked! But, now I'm confused what is the point of changing the php.ini file? It looks like I didn't even need to do that and I just had to edit the apache config file.

A follow up question is you know how there is the drop down menu with the different size uploads, my new max upload is at the top - can I select my own ranges or sizes? For example: I have 50MB, then 20MB. Can I do 50, 40, 30, 20...etc?

Thanks : )
In reply to Melissa Benson

Re: Edit php or add htaccess file?

by Marc Grober -
Have not read this whole thread so apologies if this was already addressed, but symptoms you describe are consistent with the issue of not placing necessay files in special directories under ubuntu. Have you reviewed my prior posts on this and double checked your apache directory structure?