Wednesday, April 28, 2010

Increasing File upload Size in Moodle on Ubantu

By default the upload size is 2Mb to increase the File Size limit in moodle (eg. increase limit to 50Megabytes) you will need to make the following changes:
In your php folder edit the php.ini file and change the following values:

post_max_size = 50M
upload_max_filesize = 50M

Note: On windows I had to restart IIS but I am not sure if you will need to restart apache on windows or linux.
Next go into Moodle  (in this case it is version 1.9.5) as admin and change the drop down menu’s for the following to your required size:

Courses -> Course Default Settings -> Maximum Upload Size
Modules -> Activities -> Assignment -> Maximum Size

---------------------------------------------------------------------------------------------------------------------

Modifying the php.ini file

These instructions show you how to change the file upload size by editing your php.ini file.

Ubuntu Linux Instructions

These instructions assume that you have installed the standard Moodle package, PHP 5 and Apache 2 via apt-get and left it all as a default install. If you have compiled yourself I presume that you will know where your php.ini files are!
You need to edit the following three settings in your php.ini file located at: /etc/php5/apache2/
  • Type "sudo nano /etc/php5/apache2/php.ini"
  • Press Ctrl and W and type "post_max_size"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and W and type "upload_max_filesize"
  • Change the value to the number of Mb you want your site to accept as uploads
  • Press Ctrl and W and type "max_execution_time"
  • Change the value to 600
  • Press Ctrl and O
  • Press Ctrl and X
  • Type sudo /etc/init.d/apache2 restart
Your new file size limit should now appear in Administration > Security > Site Policies > Maximum uploaded file size 
-------------------------------------------------------------------------------------------------------------------------------

Modifying the apache config file

Ubuntu Linux Instructions

You may also need to edit the config.php file in the moodle directory:
  • Type "gksudo nautilus" to get root permissions
  • Navigate to /etc/moodle
  • Open apache.conf
  • Go to the "" section
  • Change "php_value upload_max_filesize = 2M" to a higher value
  • Change "php_value post_max_size = 2M" to a higher value
  • Go to the "" section
  • Change "php_value upload_max_filesize = 2M" to a higher value
  • Change "php_value post_max_size = 2M" to a higher value
  • Save file
  • Type sudo /etc/init.d/apache2 restart


Saturday, April 24, 2010

How to Install RPM Packages

here's what I learnt and wrote down to be the standard install routines for rpm and tar.gz files.
you can find out what the switches mean by doing a rpm --help or tar --help from the command line.

Install a package
rpm –ivh packagename
upgrade a package
rpm –Uvh packagename

create a tar file
tar –cvf myfiles.tar mydir/
(add z if you are dealing with or creating .tgz (.tar.gz) files)

standard install from source
tar –xvzf Apackage.tar.gz
cd Apackage
./configure
make
make install



< Installing and upgrading RPM packages >

For installing a software package, you use the rpm command with -i option (which stands for "install"). For example, to install an RPM package called software-2.3.4.rpm:
# rpm -i software-2.3.4.rpm
If you already have some version installed on your system and want to upgrade it to the new version, you use -U option instead (which stands for "upgrade"). For example, if you have software-2.3.3.rpm installed and want to upgrade it:
# rpm -U software-2.3.4.rpm
 

cheers
Madhu Tavva

Wednesday, April 21, 2010

"Hello world" in Python CGI Web Programming in 5 minutes

I have lotta Python programs for bioinformatics research. I wanted to put them onto the web. I only developed Web apps in PHP before. And it seemed to be a big pain for porting a Python program to the web. But, I figured out in 5 minutes.
First, you need an Apache server on your Linux/Mac OS/Windows box. If you are gonna use data base, you need a database server. There are tons of blogs addressing these issues. So I won't be gossipy here. Suppose everything we mention below happens on your server-even web browsing.
Second, configure cgi in Apache. There are many ways to run a Python program on a web/http interface. I think CGI is the easiest. Assume you are on your own server and using all default settings. On Ubuntu Linux 9.04, the default configuration file for your default website is /etc/apache2/sites-available/default Open it, find the part for cgi directory, and make it like this
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
        
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
                AddHandler cgi-script .py                       # tell Apache to handle every file with .py suffix as a cgi program
                AddHandler default-handler .html .htm  # tell Apache to handle HTML files in regular way
        
The line
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
specifies the path of cgi codes and the actual directory of your program. So when you type http://127.0.0.1/cgi-bin, the Apache will look into the directory /var/www/cgi-bin/ of your localhost.
Now restart your apache. On Ubuntu Linux, by default installation and configuration, it is
sudo /etc/init.d/apache2 restart
Third, write up a Hello, World! program. Save it as hello.py and give it execution privilege for anyone.
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\

First Python HTTP Programming 




Hello World!

"""
Now open http://127.0.0.1/cgi-bin/hello.py in your web browser and you shall see a hello world in it.
If you have any error, e.g., 500 error, please check your Apache log file. It shall tell you something. You can find errors like what you have seen from a standard Python interpreter.
Reference: http://webpython.codepoint.net/cgi_tutorial

Tuesday, April 20, 2010

How to:python programming under Ubuntu | Onecore

If you are new to python programming & you’re having ubuntu linux as your operating system then you can start programming easily as Ubuntu comes up with the command line version of python pre-installed.Ubuntu community develops its own tools and scripts under python,so you can learn a lot from the community.Community also offers bounties on some of its python projects.So in that way you can also get in touch with the python developers.
In python you have two choices to learn how to program,one is with command line version and another is IDLE.I’ll explain both these methods one by one.
Command Line

Command line version of python is already installed in ubuntu.To get into python’s interactive mode,Click on Appliations>Accesorries>Terminal.Then type ‘python’ without quotes,that will open up the interactive mode of the python.Now you can test your python scripts.

You can also write the program with help of text editor like gedit or emacs.Then save it with extension .py.Now if you want to execute that file,then open the terminal,move yourself to the directory where that .py file exists.Then type the following commands in terminal.

python hello.py

this will execute the program.Once program is executed you’ll return back to the command prompt.To exit from the python interpreter type the following:


import sys;sys.exit();
or you can use exit(); or CTRL-D

This will exit from the interpreter and return back to the terminal.

IDLE
If you don’t want to use the command line version of python then there is another choice “IDLE”.IDLE means interactive developement envirement.IDLE is a Python IDE that includes a GUI debugger based on pdb.IDLE is not installed in ubuntu by default,you have to install it from DVD.To install the IDLE,follow these steps.

Click on Application>Add-remove applications.


In Add-remove applcations select categary > Programming >then Select “IDLE” check-box point.Click OK.Then it will ask for the install disk and then installs it from there.

Now you can write your program with help of text editor like emacs/gedit.Once you’re done with it,save it with extension .py.Now right click “Open with” thenĂ‚ select >IDLE. OR you can open the file from IDLE.IDLE shows the colored syntax of your program.Now to run your program,follow these steps:


Click>RUN>Run Module.

This will execute the program in the IDLE.
(Graphical user interface-GUI for Python)
Once you learn the techniques of the text processing in python.Then you need to learn how to program applications in GUI.To program GUI based applcations you have many option like Wxpython,Tkinter,Pyqt etc.
Tkinter is a GUI widget set for Python.There are many introductory tutorials for the Tkinter on the web. Some of them are :
[1] Introduction to python

[2] Python and Tkinter Programming by John Grayson (Manning, 2000, ISBN 1-884777-81-3)
[3] Tkinter reference [Here]
WxPython is another GUI toolkit for the Python programming language which allows easy creation of graphical user interfaces.You can obtain more information about Wxpython here.http://wxpython.org
You can learn more from python community so check out the activestate’s “CookBook” where you can learn a lot about the python coding.
I hope above information helps.If you have any quesstion & suggestion or errors.Then please don’t hesitate to post it over here.