Showing posts with label Cloud Servers. Show all posts
Showing posts with label Cloud Servers. Show all posts

You don't need a dedicated server to run web2py

I'm amazed at the performance and efficiency of web2py framework. Most python frameworks are memory hogs and I wouldn't run the application in anything under 512M of memory.  But web2py seems very tight and efficient and quite capable to run in some of the smaller footprints offered by some cloud providers.

I personally use and of course recommend Rackspace Cloud (aff.) where the smallest instance is 256M of RAM with 10G of disk space with larger offerings that give you options to expand this modest VM into a large scale cloud server that rivals a dedicated server

Even with the growth options Rackspace offers, you want to keep your installation tight and to a minimum. There are many Linux flavors, but Ubunto is about the simplest to use for managing your server and like most cloud providers, Rackspace has the latest version LTS 10.04 pre-built and ready to deploy for you.

You probably could get by with a simple Linux-Apache-Python (LAP) install since web2py uses sqlite3 as the database for the model, but a LAMP (+mysql/postgresql) will fit into the reduced memory size.

The following script will install everything you need

wget web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh
chmod +x setup-web2py-ubuntu.sh
./setup-web2py-ubuntu.sh

This will put your web2py install in /home/www-data/web2py.

You may have to run web2py directly from the command line once so that the remainder of the directories and files are created.  This is not done for you in the setup script since it basically configures Apache and starts up web2py via the wsgi.

Just run:

python web2py.py -a "hello"

to create a dummy application and your web2py server running on Ubuntu should be ready to go.

How to Install Apache on Your Dedicated Server

In this lesson you will learn how to install Apache on your Dedicated Server.  If you don't yet have a Dedicated Server on site at your home office or facility, the best thing to do is to open an account at the Rackspace Cloud.  Provision a 256 MB Ubuntu cloud server.  This will run you about $10/month or a few cents per hour if you decide to unprovision the server after completing this lesson.

Apache Web server Installation in Ubuntu
Ubuntu Linux is a great platform to use for an Apache Web server Installation. From a simple machine you can serve web pages to an Intranet or the Internet using one of the most popular Web server configurations.

LAMP Server

For new installations of Ubuntu, the easiest method to get the Apache Web server is by selecting the “LAMP” option on Ubuntu’s software selection screen during installation. This process will get the standard Linux, Apache, MySQL, PHP configuration setup on your server in one automated process.

If you don’t want to configure the server as a LAMP, or if you have other requirements, you can install Apache as a separate application once Ubuntu is installed.

If you went the Rackspace Cloud route, Rackspace has images of Ubuntu already provisioned so you get to skip the installation process and just jump to the Apache installation step.

Download and install Apache Web server

Open a putty session to your server and type “sudo apt-get install apache2” and then press return.

Ubuntu will download and install the Apache Web server software. When the process is complete, you can test your Web server by loading http://localhost (or the IP address assigned to your server) in a browser.

Edit apache2.conf

If the default Apache page doesn’t load, you can try editing the apache2.conf file. Just type in “sudo nano /etc/apache2/apache2.conf” and then press enter to edit the file in Nano. Add the line, “ServerName localhost” to the file and then save and exit. Every time you change apache2.conf you should restart the Apache server so the changes will take effect. Type in sudo apache2ctl restart and press . When this is finished, try browsing to “localhost” in your Firefox browser.

Other considerations

Most of the time, people want to use PHP with Apache. To do this, all you have to do is type “sudo aptitude install php5 libapache2-mod-php5” into a terminal window and then press . If you need to have PHP4 installed, type in “sudo aptitude install php4 libapache2-mod-php4” and then press .

After that, enable the PHP modules by typing in “sudo a2enmod php4” and then pressing and then type “sudo a2enmod php5” followed by hitting the key. Type in sudo apache2ctl restart and press .


As you have seen, Apache Web server installation is really easy in Ubuntu. You can continue to add modules to Apache such as CGI and Perl if necessary. The Apache Web server is one of the most powerful available and is capable of running the most sophisticated Web applications.