Project

General

Profile

Setup And Install » History » Version 14

Luke Murphey, 04/01/2016 08:05 PM

1 1 Luke Murphey
h1. Setup And Install
2 1 Luke Murphey
3 2 Luke Murphey
Below are instructions for how to run your own instance of TextCritical.
4 2 Luke Murphey
5 1 Luke Murphey
h2. Install Prerequisites
6 1 Luke Murphey
7 2 Luke Murphey
To run TextCritical, you will need:
8 2 Luke Murphey
9 13 Luke Murphey
* "Django 1.8+":https://www.djangoproject.com/download/
10 1 Luke Murphey
* "Python 2.7":http://www.python.org/getit/
11 13 Luke Murphey
* "Grappelli":http://django-grappelli.readthedocs.org/en/latest/quickstart.html#installation
12 1 Luke Murphey
* A database (you can use SQLite to avoid extensive database setup)
13 9 Luke Murphey
14 9 Luke Murphey
You will need to install "Genshi":http://genshi.edgewall.org/wiki/Download and lxml.
15 2 Luke Murphey
16 10 Luke Murphey
h2. Install TextCritical App Code
17 1 Luke Murphey
18 2 Luke Murphey
Check out the source code from http://svn.lukemurphey.net/textcritical.com using a "Subversion client":http://en.wikipedia.org/wiki/Comparison_of_Subversion_clients.
19 2 Luke Murphey
20 2 Luke Murphey
Copy start_here_settings.py to settings.py (under the src directory). Update the settings.py file per your host.
21 2 Luke Murphey
22 10 Luke Murphey
h2. Configure and Initialize Database
23 1 Luke Murphey
24 2 Luke Murphey
Specify a database in settings.py unless you intend to use SQLite.
25 2 Luke Murphey
26 2 Luke Murphey
After configuring the database, run syncdb (from the src directory):
27 2 Luke Murphey
28 1 Luke Murphey
<pre>
29 1 Luke Murphey
python manage.py syncdb
30 1 Luke Murphey
</pre>
31 1 Luke Murphey
32 1 Luke Murphey
h2. Import Works
33 1 Luke Murphey
34 1 Luke Murphey
You will need to import the works into the library in order to have something for the site to provide access to. The easy way to do this is to use a prebuilt library. The more difficult way is to import the works yourself.
35 1 Luke Murphey
36 1 Luke Murphey
h3. Using Existing Library
37 1 Luke Murphey
38 1 Luke Murphey
To use an existing library, copy the library.sqlite file to the server. By default, it should be placed in the src directory.
39 1 Luke Murphey
40 1 Luke Murphey
h3. Importing Works
41 1 Luke Murphey
42 1 Luke Murphey
If you want to import works manually, then following the steps below.
43 1 Luke Murphey
44 1 Luke Murphey
First, initialize the library database.
45 1 Luke Murphey
46 1 Luke Murphey
<pre>
47 1 Luke Murphey
python manage.py syncdb --database=library
48 1 Luke Murphey
</pre>
49 1 Luke Murphey
50 2 Luke Murphey
Next, download the relevant works. The Perseus works can be obtained from "Perseus.tufts.edu":http://www.perseus.tufts.edu/hopper/opensource/download. Make sure to get the classics library. Decompress the archive.
51 1 Luke Murphey
52 2 Luke Murphey
Start the import process by running the following command, substituting "/Users/Luke/Perseus_Directory" with the location where you placed the files:
53 1 Luke Murphey
54 1 Luke Murphey
<pre>
55 1 Luke Murphey
python manage.py batch_import_perseus -d "/Users/Luke/Perseus_Directory"
56 1 Luke Murphey
</pre>
57 1 Luke Murphey
58 6 Luke Murphey
The import process may take a while (it takes about 70 minutes on a Core i7 with 8 GB of RAM). *Make sure to set DEBUG to False* before running the import. Otherwise, memory consumption will grow until the import completes.
59 2 Luke Murphey
60 8 Luke Murphey
h3. Indexing Works
61 8 Luke Murphey
62 8 Luke Murphey
You'll need to index the works for the search engine to work properly.
63 8 Luke Murphey
64 8 Luke Murphey
After importing the works, run the following:
65 8 Luke Murphey
66 8 Luke Murphey
<pre>
67 8 Luke Murphey
python manage.py make_search_indexes -c
68 8 Luke Murphey
</pre>
69 8 Luke Murphey
70 1 Luke Murphey
h2. Start Web Server
71 2 Luke Murphey
72 4 Luke Murphey
For production installs, you ought to use a production web-server like Apache. For development, you can use the built in Django web-server:
73 1 Luke Murphey
74 1 Luke Murphey
<pre>
75 1 Luke Murphey
python manage.py runserver 0.0.0.0:8080
76 4 Luke Murphey
</pre>
77 4 Luke Murphey
78 4 Luke Murphey
Alternatively, you can use the included CherryPy server which should be good enough for production use. To use it, start "run_server.py" after setting WEB_SERVER_ADDRESS and WEB_SERVER_PORT in settings.py; example below:
79 4 Luke Murphey
80 4 Luke Murphey
<pre>
81 4 Luke Murphey
<code class="python">
82 4 Luke Murphey
# The address and port to use when using the built-in web-server
83 4 Luke Murphey
WEB_SERVER_ADDRESS = '0.0.0.0' # Use '127.0.0.1' to serve content to localhost only
84 4 Luke Murphey
WEB_SERVER_PORT    = 8080
85 4 Luke Murphey
</code>
86 2 Luke Murphey
</pre>
87 3 Luke Murphey
88 11 Luke Murphey
You can use lighttpd to serve as a reverse proxy to CherryPy. Below is a lighttpd config that will proxy to CherryPy or the Django web-server:
89 11 Luke Murphey
90 11 Luke Murphey
<pre>
91 11 Luke Murphey
# Define the location of text critical here:
92 11 Luke Murphey
var.textcriticalpath = "/Users/lmurphey/Documents/SP/Workspace/TextCritical.com"
93 11 Luke Murphey
94 11 Luke Murphey
# This is IP of the web-server:
95 11 Luke Murphey
var.proxyserver = "127.0.0.1"
96 11 Luke Murphey
97 11 Luke Murphey
# This is the port that Django server is running on:
98 11 Luke Murphey
var.proxyport = 8080
99 11 Luke Murphey
100 11 Luke Murphey
# This is the port to run the web-server on:
101 11 Luke Murphey
var.serverport = 8081
102 11 Luke Murphey
103 11 Luke Murphey
server.modules = ( "mod_proxy" )
104 11 Luke Murphey
105 11 Luke Murphey
$HTTP["url"] !~ "^/media/" {
106 11 Luke Murphey
	proxy.server = ( "" =>
107 11 Luke Murphey
	                       ( ( 
108 11 Luke Murphey
	                           "host" => var.proxyserver,
109 11 Luke Murphey
	                           "port" => var.proxyport
110 11 Luke Murphey
	                       ) )
111 11 Luke Murphey
	               )
112 11 Luke Murphey
}
113 11 Luke Murphey
114 11 Luke Murphey
server.document-root = var.textcriticalpath + "/src"
115 11 Luke Murphey
116 11 Luke Murphey
server.port = var.serverport
117 11 Luke Murphey
118 11 Luke Murphey
mimetype.assign = (
119 11 Luke Murphey
  ".html" => "text/html", 
120 11 Luke Murphey
  ".txt" => "text/plain",
121 11 Luke Murphey
  ".jpg" => "image/jpeg",
122 11 Luke Murphey
  ".png" => "image/png",
123 11 Luke Murphey
  ".css" => "text/css",
124 11 Luke Murphey
  ".js" => "application/javascript"  
125 11 Luke Murphey
)
126 11 Luke Murphey
</pre>
127 11 Luke Murphey
128 12 Luke Murphey
h2. Upgrading
129 12 Luke Murphey
130 12 Luke Murphey
If you are upgrading an existing install from one of the older versions that supported Django 1.5, then you will need to do several things.
131 12 Luke Murphey
132 12 Luke Murphey
First, install Django 1.8:
133 12 Luke Murphey
134 12 Luke Murphey
<pre>
135 12 Luke Murphey
pip install Django==1.8.6
136 12 Luke Murphey
</pre>
137 12 Luke Murphey
138 12 Luke Murphey
Next, migrate the database:
139 12 Luke Murphey
140 12 Luke Murphey
<pre>
141 12 Luke Murphey
python manage.py migrate
142 12 Luke Murphey
</pre>
143 12 Luke Murphey
 
144 7 Luke Murphey
h2. Common Setup Issues
145 3 Luke Murphey
146 3 Luke Murphey
h3. Syncdb Fails Saying it couldn't create "django_content_type"
147 3 Luke Murphey
148 3 Luke Murphey
This has something to do with database routing. It can be solved by adding the following to the settings.py file and re-running syncdb:
149 3 Luke Murphey
150 3 Luke Murphey
<pre>
151 3 Luke Murphey
DATABASE_ROUTING = []
152 3 Luke Murphey
</pre>
153 3 Luke Murphey
154 5 Luke Murphey
Once syncdb succeeds, delete this line.
155 5 Luke Murphey
156 5 Luke Murphey
Reference: https://code.djangoproject.com/ticket/16039
157 5 Luke Murphey
158 3 Luke Murphey
h3. Syncdb Fails When Creating Superuser
159 3 Luke Murphey
160 3 Luke Murphey
<pre>
161 3 Luke Murphey
You just installed Django's auth system, which means you don't have any superusers defined.                                                 
162 3 Luke Murphey
Would you like to create one now? (yes/no): yes                                                                                             
163 3 Luke Murphey
Traceback (most recent call last):                                                                                                          
164 3 Luke Murphey
  File "manage.py", line 10, in <module>                                                                                                    
165 3 Luke Murphey
    execute_from_command_line(sys.argv)                                                                                                     
166 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line                  
167 3 Luke Murphey
    utility.execute()                                                                                                                       
168 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute                                    
169 3 Luke Murphey
    self.fetch_command(subcommand).run_from_argv(self.argv)                                                                                 
170 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv                                  
171 3 Luke Murphey
    self.execute(*args, **options.__dict__)                                                                                                 
172 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute                                        
173 3 Luke Murphey
    output = self.handle(*args, **options)                                                                                                  
174 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle                                         
175 3 Luke Murphey
    return self.handle_noargs(**options)                                                                                                    
176 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs                       
177 3 Luke Murphey
    emit_post_sync_signal(created_models, verbosity, interactive, db)                                                                       
178 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal                           
179 3 Luke Murphey
    interactive=interactive, db=db)                                                                                                         
180 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send                                            
181 3 Luke Murphey
    response = receiver(signal=self, sender=sender, **named)                                                                                
182 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser                    
183 3 Luke Murphey
    call_command("createsuperuser", interactive=True, database=db)                                                                          
184 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command                               
185 3 Luke Murphey
    return klass.execute(*args, **defaults)                                                                                                 
186 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute                                        
187 3 Luke Murphey
    output = self.handle(*args, **options)                                                                                                  
188 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle              
189 3 Luke Murphey
    default_username = get_default_username()                                                                                               
190 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username               
191 3 Luke Murphey
    default_username = get_system_username()                                                                                                
192 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username                 
193 3 Luke Murphey
    return getpass.getuser().decode(locale.getdefaultlocale()[1])                                                                           
194 3 Luke Murphey
TypeError: decode() argument 1 must be string, not None   
195 3 Luke Murphey
</pre>
196 3 Luke Murphey
197 3 Luke Murphey
You may need to set your locale by running the following before running syncdb:
198 3 Luke Murphey
199 3 Luke Murphey
<pre>
200 3 Luke Murphey
export LC_ALL="en_US.UTF-8"
201 3 Luke Murphey
</pre>
202 3 Luke Murphey
203 3 Luke Murphey
Delete the auth_users table and do another syncdb to try again.
204 1 Luke Murphey
205 1 Luke Murphey
Reference: https://code.djangoproject.com/ticket/16017
206 7 Luke Murphey
207 7 Luke Murphey
h3. "__init__() keywords must be strings" when running Perseus Importer
208 7 Luke Murphey
209 7 Luke Murphey
This is caused by a "known bug in Python 2.6":http://bugs.python.org/issue2646 in which unicode arguments are not handled correctly. Upgrading to Python 2.7 resolves the issue.
210 14 Luke Murphey
211 14 Luke Murphey
h2. Upgrading
212 14 Luke Murphey
213 14 Luke Murphey
When you upgrade a TextCritical instance, you may need to clear some caches including:
214 14 Luke Murphey
* The web cache
215 14 Luke Murphey
* The cache eBooks (in /media/files)
216 14 Luke Murphey
217 14 Luke Murphey
The cache of eBooks can be rebuilt by running the Django commands +make_epubs+ and +make_mobi+.