Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 27 and Version 28 of TurboGearsOnDreamHost


Ignore:
Timestamp:
07/06/06 16:36:26 (11 years ago)
Author:
mikez0r
Comment:

added mod_rewrite method

Legend:

Unmodified
Added
Removed
Modified
  • TurboGearsOnDreamHost

    v27 v28  
    11= Introduction = 
    22 
    3 Users of the DreamHost.com (DH) hosting service are now able to run TurboGears (TG) applications behind Apache using FastCGI.  This page describes the steps required for enabling TG as a FastCGI application on the DH servers. 
     3Users of the DreamHost.com (DH) hosting service have at least 2 options for running TurboGears (TG) applications - one is through using FastCGI, the other is to use mod_rewrite, or potentially mod_proxy if DH gets around to installing that (not there as of July 06, 2006).  This page describes the steps required for either option.  Mod_rewrite is a good bit simpler. 
    44 
    55    Note: If you do happen to sign up for DreamHost, please use this link to support TurboGears development: http://www.dreamhost.com/r.cgi?turbogears [[BR]] 
    66    Also: Kevin Dangoor posted a caution about TG on DH [http://groups.google.com/group/turbogears/browse_thread/thread/c1c81ae56f37e444/3422a35cfa5bf985?hl=en#3422a35cfa5bf985 here] 
     7 
     8= Common Steps: = 
     9 
     10= Installation = 
     11 
     12== Download Installation Files == 
     13 
     14A few files will need to be downloaded before starting the installation.  To make it easier to clean up later, you should create a new directory to store these files (e.g. /$HOME/download/turbogears).  Switch to the download directory and issue the following commands: 
     15 
     16 
     17{{{ 
     18# Used for TurboGears Download/Installation 
     19wget http://www.turbogears.org/download/ez_setup.py 
     20 
     21# Current Python Download 
     22wget http://www.python.org/ftp/python/2.4.2/Python-2.4.2.tgz 
     23}}} 
     24 
     25 
     26== Create a Custom Python Installation == 
     27 
     28Because of DH’s current Python setup (the python-dev package is not installed... although they will install it if you ask them to), you will need to create a custom Python installation for your account.  Issue the following commands from the directory where the Python-X.X.X.tgz file is located: 
     29 
     30 
     31{{{ 
     32#Unpack Python 
     33tar -zxvf Python-2.4.2.tgz 
     34 
     35#Change to the Python directory 
     36cd Python-2.4.2 
     37 
     38#Run configure and enable Unicode 
     39./configure --prefix=$HOME/lib --enable-unicode=ucs4 
     40make 
     41make install 
     42}}} 
     43 
     44Python is now installed, however, you will need to make your installation the default version: 
     45 
     46{{{ 
     47# Create a home directory for Python 
     48mkdir $HOME/bin 
     49mkdir $HOME/bin/python 
     50mkdir $HOME/bin/python/bin 
     51 
     52# Create a link to the python executable. 
     53ln -s $HOME/lib/bin/python $HOME/bin/python/bin/python 
     54 
     55# Edit your bash_profile 
     56cd ~ 
     57vim .bash_profile 
     58 
     59# Add the following line then save the file:  
     60export PATH=$HOME/bin/python/bin:$HOME/lib/bin:$PATH 
     61 
     62# Reload the file 
     63source ~/.bash_profile 
     64}}} 
     65 
     66 
     67Type 'python'.  You should see output similar to the following: 
     68 
     69 
     70{{{ 
     71Python 2.4.2 (#3, Dec 10 2005, 10:22:59) 
     72[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2 
     73Type "help", "copyright", "credits" or "license" for more information. 
     74>>> 
     75}}} 
     76 
     77 
     78== TurboGears Installation == 
     79 
     80Navigate to the directory where the ez_setup.py (downloaded earlier) file is located.  Issue the following command to install TurboGears: 
     81 
     82 
     83{{{ 
     84python ez_setup.py -f http://www.turbogears.org/download/index.html TurboGears 
     85}}} 
     86 
     87If you want to get 0.9 instead, the command is: 
     88 
     89{{{ 
     90python ez_setup.py -f http://www.turbogears.org/preview/download/index.html TurboGears 
     91}}} 
     92 
     93You can also get the SVN version to be on the forefront of development efforts. 
     94 
     95TurboGears should now be installed.  Typing ‘tg-admin’ should display output similar to the following: 
     96 
     97 
     98{{{ 
     99$ tg-admin 
     100 
     101TurboGears 0.8a5 command line interface 
     102 
     103Usage: /home/cubano/lib/bin/tg-admin [command] [options] 
     104 
     105Available commands: 
     106quickstart  Create a new TurboGears project 
     107     shell  Start a Python prompt with your database available 
     108       sql  Run the SQLObject manager 
     109}}} 
     110 
     111 
     112 
     113If you are testing your installation with the wiki20 example, you will also need to install the docutils package: 
     114 
     115 
     116{{{ 
     117easy_install docutils 
     118}}} 
     119 
     120 
     121If you are using sqlite, you will need to install the pysqlite package: 
     122 
     123 
     124{{{ 
     125easy_install pysqlite 
     126}}} 
     127 
     128For MySQL users, do the following to install the Python/MySQL library package: 
     129 
     130{{{ 
     131# Download the file - Check for newer versions at http://sourceforge.net/project/showfiles.php?group_id=22307   
     132# This is the current version as of Apr 13, 2006 
     133wget http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.1_p2.tar.gz 
     134 
     135# Unpack the archive 
     136tar -xvvzf MySQL-python-1.2.1_p2.tar.gz 
     137 
     138# Install the archive 
     139cd MySQL-python-1.2.1_p2 
     140python setup.py install 
     141}}} 
     142 
     143Note: It's also possible to use easy_install to create an egg of MySQL-Python: 
     144{{{ 
     145wget http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.1_p2.tar.gz 
     146 
     147easy_install MySQL-python-1.2.1_p2.tar.gz 
     148}}} 
     149 
     150= Steps for mod_rewrite = 
     151 
     152== Create a .htaccess file == 
     153This file will filter requests from your apache server and redirect them to the port that Turbogears will be listening on.  In this example, anything that is not in the stats or static folder, or the failed_auth.html file will get redirected to Cherrypy on your port.  Make sure you change the line for your needs. 
     154 
     155{{{ 
     156RewriteEngine On 
     157 
     158RewriteRule !^((stats|static)(/.*)?|failed_auth\.html)$ http://www.yourwebsite.com:YOUR_PORT_NUMBER%{REQUEST_URI} [R,L] 
     159}}} 
     160 
     161== Edit your dev.cfg or prod.cfg file == 
     162Dreamhost does not shut down ports willy-nilly, so you can pretty much just pick a port to run your app on.  Try one, and if it's taken, just try another.  You obviously won't be able to take port 80, or the other standard ports, but high numbers will probably not be taken. 
     163 
     164You need a line like this in dev.cfg or prod.cfg (whichever one you're using): 
     165{{{ 
     166server.socket_port=4517 
     167}}} 
     168 
     169== Start up TG and test == 
     170Start TG just as you would with a normal install - go to your project directory and issue a ./start-projectname.py 
     171 
     172to leave the server running after the terminal is closed: 
     173{{{ 
     174./start-projectname.py & 
     175}}} 
     176 
     177There are probably better ways to do this - feel free to add to this! 
     178 
     179At this point, navigating to www.yoursite.com should redirect you to www.yoursite.com:YOUR_PORT_NUMBER, where your TG app will hopefully be waiting to happily answer requests. 
     180 
     181= Alternative: deployment through FastCGI = 
    7182 
    8183= Prerequisites = 
     
    14189 1. Click on the “Edit” link under the “Web Hosting” column next to the domain that you would like to enable. 
    15190 1. Click on the “FastCGI Support?” option, and then save your settings. 
    16  
    17 = Installation = 
    18  
    19 == Download Installation Files == 
    20  
    21 A few files will need to be downloaded before starting the installation.  To make it easier to clean up later, you should create a new directory to store these files (e.g. /$HOME/download/turbogears).  Switch to the download directory and issue the following commands: 
    22  
    23  
    24 {{{ 
    25 # Used for TurboGears Download/Installation 
    26 wget http://www.turbogears.org/download/ez_setup.py 
    27  
    28 # Current Python Download 
    29 wget http://www.python.org/ftp/python/2.4.2/Python-2.4.2.tgz 
    30 }}} 
    31  
    32  
    33 == Create a Custom Python Installation == 
    34  
    35 Because of DH’s current Python setup (the python-dev package is not installed... although they will install it if you ask them to), you will need to create a custom Python installation for your account.  Issue the following commands from the directory where the Python-X.X.X.tgz file is located: 
    36  
    37  
    38 {{{ 
    39 #Unpack Python 
    40 tar -zxvf Python-2.4.2.tgz 
    41  
    42 #Change to the Python directory 
    43 cd Python-2.4.2 
    44  
    45 #Run configure and enable Unicode 
    46 ./configure --prefix=$HOME/lib --enable-unicode=ucs4 
    47 make 
    48 make install 
    49 }}} 
    50  
    51 Python is now installed, however, you will need to make your installation the default version: 
    52  
    53 {{{ 
    54 # Create a home directory for Python 
    55 mkdir $HOME/bin 
    56 mkdir $HOME/bin/python 
    57 mkdir $HOME/bin/python/bin 
    58  
    59 # Create a link to the python executable. 
    60 ln -s $HOME/lib/bin/python $HOME/bin/python/bin/python 
    61  
    62 # Edit your bash_profile 
    63 cd ~ 
    64 vim .bash_profile 
    65  
    66 # Add the following line then save the file:  
    67 export PATH=$HOME/bin/python/bin:$HOME/lib/bin:$PATH 
    68  
    69 # Reload the file 
    70 source ~/.bash_profile 
    71 }}} 
    72  
    73  
    74 Type 'python'.  You should see output similar to the following: 
    75  
    76  
    77 {{{ 
    78 Python 2.4.2 (#3, Dec 10 2005, 10:22:59) 
    79 [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2 
    80 Type "help", "copyright", "credits" or "license" for more information. 
    81 >>> 
    82 }}} 
    83  
    84  
    85 == TurboGears Installation == 
    86  
    87 Navigate to the directory where the ez_setup.py (downloaded earlier) file is located.  Issue the following command to install TurboGears: 
    88  
    89  
    90 {{{ 
    91 python ez_setup.py -f http://www.turbogears.org/download/index.html TurboGears 
    92 }}} 
    93  
    94 If you want to get 0.9 instead, the command is: 
    95  
    96 {{{ 
    97 python ez_setup.py -f http://www.turbogears.org/preview/download/index.html TurboGears 
    98 }}} 
    99  
    100 You can also get the SVN version to be on the forefront of development efforts. 
    101  
    102 TurboGears should now be installed.  Typing ‘tg-admin’ should display output similar to the following: 
    103  
    104  
    105 {{{ 
    106 $ tg-admin 
    107  
    108 TurboGears 0.8a5 command line interface 
    109  
    110 Usage: /home/cubano/lib/bin/tg-admin [command] [options] 
    111  
    112 Available commands: 
    113 quickstart  Create a new TurboGears project 
    114      shell  Start a Python prompt with your database available 
    115        sql  Run the SQLObject manager 
    116 }}} 
    117  
    118  
    119  
    120 If you are testing your installation with the wiki20 example, you will also need to install the docutils package: 
    121  
    122  
    123 {{{ 
    124 easy_install docutils 
    125 }}} 
    126  
    127  
    128 If you are using sqlite, you will need to install the pysqlite package: 
    129  
    130  
    131 {{{ 
    132 easy_install pysqlite 
    133 }}} 
    134  
    135 For MySQL users, do the following to install the Python/MySQL library package: 
    136  
    137 {{{ 
    138 # Download the file - Check for newer versions at http://sourceforge.net/project/showfiles.php?group_id=22307   
    139 # This is the current version as of Apr 13, 2006 
    140 wget http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.1_p2.tar.gz 
    141  
    142 # Unpack the archive 
    143 tar -xvvzf MySQL-python-1.2.1_p2.tar.gz 
    144  
    145 # Install the archive 
    146 cd MySQL-python-1.2.1_p2 
    147 python setup.py install 
    148 }}} 
    149  
    150 Note: It's also possible to use easy_install to create an egg of MySQL-Python: 
    151 {{{ 
    152 wget http://switch.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.1_p2.tar.gz 
    153  
    154 easy_install MySQL-python-1.2.1_p2.tar.gz 
    155 }}} 
    156191 
    157192== FastCGI Installation ==