HKCS eXtreme Contest Sustainable Campus
I am glad to participate in the HKCS extreme contest. The following is my entry for this year:
I am glad to participate in the HKCS extreme contest. The following is my entry for this year:
Introduction
I have managed to install python, mod_python, and Django on one of my Linux servers. This howto has been proven to work along with CentOS 4.3 and Apache 2.0.63.
Install Python
Python is bundled on most Linux distro. If you are using Ubutu, CentOS, or any other distro that use yum as the package manager, you may skip this step because yum is written in python.
If Python is installed, you can check its version by running:
If you don’t have it, install it using yum:
The Python version from the yum repository for CentOS 4 is 2.3.4, if you want the lastest stable version, you will need to compile it from source.
Install mod_python
mod_python is an Apache module that embeds Python within Apache and loads Python code into memory when the server starts. It allows you to write Python code with HTML embedded just like PHP.
Configure mod_python to work with Apache
Edit your httpd.conf, add:
Dont forget to change the path to the mod_python.so
Install Django
Configure Django
In your home directory, run:
This will create the directory /path/to/your/home/directory/project with some Python files in it.
Then edit your httpd.conf file and add the following:
Restart Apache
Restart Apache to enable the new settings:
Now you can access http://www.example.com/project in a browser. If everything went well, you should see something like this:
Create a New Django Project
Congratulations! You can now start developing your Django application!
In python 2.6 or below, “print” is just a simple statement to print output:
Now the print statement is replaced by the print() function in Python 3.0:
To suppress the trailing new line:
The above code will print: Hello World! Hello World again!
Reference: What’s New in Python 3.0
Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes