Q: Basic deployment questions: CherryPy on Ubuntu I have a modest CherryPy / SQLite application under development.  I would like to put it on a server in the cloud for client testing.  Towards that end I've spun up a small Ubuntu instance at Rackspace and done some preliminary installation (setup-tools and CherryPy).
Not being either an administrator or particularly familiar with Linux I have some rather simple questions about deploying this application that I haven't been able to answer using Google:


*

*I assume I should create a user account specifically to run the application rather than using root or any other existing account?

*I'm not sure where I should transplant my application folders.  I'm guessing that they should go in /usr/user-I-created-question-1/.  Is that correct?

*I'm using the CherryPy server which appears to be sufficient to my needs for this application.  Is the correct approach to start the application in a putty session then kill the putty session on my Windows machine?

*Aside from visiting the site myself, what tools or techniques exist to monitor up-time, or to know if the server has become unavailable?

A: You know, if it's only for testing for a limited amount of time, it's probably fine running the way you are talking about.  Though it's probably also fine, under those circumstances, to run as any user.  It's probably best to create a non-privileged user and have it run under that.
Where do you put it?  Probably in a sub-directory of that users' home directory, like "/home/username/mywebapp".
You will probably want to run "screen" (apt-get install it if it isn't there), and run the web-app under that.  You can re-attach with "screen -x" and you can detach from it with "Control-A COntrol-D".  That way it won't die when you disconnect.
However, the way I would do it is to run it under Apache, so Apache starts and stops the app.  It also then runs under the Apache user, which may be good or bad, but is usually good.  Typically that would involve:


*

*Using mod_wsgi.

*Create a file in /etc/apache2/conf.d named after your application.


It should contain:
WSGIPythonPath /path/to/webapp/root
WSGIScriptAlias /appname /path/to/webapp/root/controller.py



*

*In this case your webapp would be in the "controller.py" file.  The "/appname" is the part of the URL that accesses this app, for example: http://127.0.0.1/appname

*That webapp then needs to be a WSGI app, for example it should end with:


WSGI Example:
cfg = config()
cherrypy.config.update()
application = cherrypy.APplication(None, script_name = '/appname', config = cfg)

The key thing is that you need to create an "application" object in your controller.
Once you do that, you should be able to restart Apache (/etc/init.d/apache2 restart) and then access the webapp via that URL.
