Tonton MyTV dilengkapi intisari rancangan pada smart TV bermula RM4.99 sebulan. Selanjutnya →

Deploy Turbogears 2.1 on Fedora

Jumaat, 19 Februari 2010, 5:27 pm0

(Update: Using Fedora 16)

Install mod_wsgi for apache

yum install mod_wsgi

Edit apache config: (/etc/httpd/conf/httpd.conf)

ServerName hostname:80

Workaround for mod_wsgi 2.x in Fedora, move this line:

Include conf.d/*.conf

… to below these lines:

User apache
Group apache

Add this to the end of the config file: (/etc/httpd/conf.d/wsgi.conf)

<IfModule mod_wsgi.c>
  WSGISocketPrefix /var/run/wsgi
</IfModule>

Using TG2 demo app from the previous post (HelloWorld), create apache config file for this app: (/etc/httpd/conf.d/HelloWorld.conf)

Listen 8080
NameVirtualHost *:8080

<VirtualHost *:8080>

  ServerAdmin webmaster@hostname
  ServerName hostname
  ErrorLog logs/hostname-error_log
  CustomLog logs/hostname-access_log common

  Alias /images/ /var/www/HelloWorld/images/
  Alias /css/ /var/www/HelloWorld/css/
  Alias /javascript/ /var/www/HelloWorld/javascript/

  WSGIDaemonProcess HelloWorld threads=10 processes=3
  WSGIProcessGroup HelloWorld
  WSGIScriptAlias / /var/www/HelloWorld/HelloWorld.wsgi
<Directory /var/www/HelloWorld> Order deny,allow Allow from all </Directory> </VirtualHost>

Create directory for static contents (do these as root):

mkdir -p /var/www/HelloWorld/python-eggs

Create wsgi script for apache to launch this app: (/var/www/HelloWorld/HelloWorld.wsgi)

import os, sys, site
appname = 'HelloWorld'
prev_sys_path = list(sys.path)
site.addsitedir('/usr/local/pythonenv/%s/lib/python2.6/site-packages' % appname)
new_sys_path = []
for item in list(sys.path):
    if item not in prev_sys_path:
        new_sys_path.append(item)
        sys.path.remove(item)
sys.path[:0] = new_sys_path
sys.path.append('/usr/local/turbogears/%s' % appname)
from pkg_resources import working_set, Environment
env = Environment('/usr/local/pythonenv/%s' % appname)
env.scan()
distributions, errors = working_set.find_plugins(env)
for dist in distributions:
    working_set.add(dist)
os.environ['PYTHON_EGG_CACHE'] = '/usr/local/turbogears/%s/python-eggs' % appname
from paste.deploy import loadapp
application = loadapp('config:/usr/local/turbogears/%s/production.ini' % appname)

Move TG2 public folder to static contents folder:

cp -r HelloWorld/helloworld/public/* /var/www/HelloWorld
chown -R apache.apache /var/www/HelloWorld

Move TG2 app to application folder:

mkdir -p /usr/local/turbogears
cp -r HelloWorld/ /usr/local/turbogears/

Create production config file of the app:

cd /usr/local/turbogears/HelloWorld
cp development.ini production.ini

Set debug to false: (/usr/local/turbogears/HelloWorld/production.ini)

debug=false

Set permission:

chown -R apache.apache /usr/local/turbogears

Finally, restart apache:

service httpd restart

Now, browse to http://localhost:8080

Batch image resize

19 Februari 2010

Tulis komen: