7 3. Running OSQA in the development server
8 4. Installation under Apache/WSGI
10 6. Email subscriptions
13 C. CONFIGURATION PARAMETERS (settings_local.py)
18 -----------------------------------------------
19 0. We recommend you to use python-setuptools to install pre-requirement libraries.
20 If you haven't installed it, please try to install it first.
21 e.g, sudo apt-get install python-setuptools
23 1. Python2.5/2.6, MySQL, Django v1.0/1.1
24 Note: email subscription sender job requires Django 1.1, everything else works with 1.0
25 Make sure mysql for python provider has been installed.
26 sudo easy_install mysql-python
29 http://openidenabled.com/python-openid/
30 sudo easy_install python-openid
33 http://code.google.com/p/html5lib/
34 Used for HTML sanitizer
35 sudo easy_install html5lib
38 http://code.google.com/p/python-markdown2/
39 sudo easy_install markdown2
41 6. Django Debug Toolbar
42 http://github.com/robhudson/django-debug-toolbar/tree/master
44 7. djangosphinx (optional - for full text questions+answer+tag)
45 http://github.com/dcramer/django-sphinx/tree/master/djangosphinx
47 8. sphinx search engine (optional, works together with djangosphinx)
48 http://sphinxsearch.com/downloads.html
51 http://code.google.com/p/recaptcha-django/
53 10. python recaptcha module
54 http://code.google.com/p/recaptcha/
55 Notice that you will need to register with recaptcha.net and receive
56 recaptcha public and private keys that need to be saved in your
57 settings_local.py file
59 NOTES: django_authopenid is included into OSQA code
60 and is significantly modified. http://code.google.com/p/django-authopenid/
61 no need to install this library
64 -----------------------------------------------
65 0. Make sure you have all above python libraries installed.
67 make osqa installation server-readable on Linux command might be:
68 chown -R yourlogin:apache /path/to/OSQA
70 directories templates/upfiles and log must be server writable
73 chmod -R g+w /path/to/OSQA/upfiles
74 chmod -R g+w /path/to/log
76 above it is assumed that webserver runs under group named "apache"
80 Copy settings_local.py.dist to settings_local.py and
81 update all your settings. Check settings.py and update
82 it as well if necessory.
83 Section C explains configuration paramaters.
87 Prepare your database by using the same database/account
88 configuration from above.
90 create database osqa DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
91 grant all on osqa.* to 'osqa'@'localhost';
92 And then run "python manage.py syncdb" to synchronize your database.
94 3. Running OSQA on the development server
96 Run "python manage.py runserver" to startup django
97 development environment.
98 (Under Linux you can use command "python manage.py runserver `hostname -i`:8000",
99 where you can use any other available number for the port)
101 you might want to have DEBUG=True in the beginning of settings.py
102 when using the test server
104 4. Installation under Apache/WSGI
106 4.1 Prepare wsgi script
108 Make a file readable by your webserver with the following content:
114 sys.path.insert(0,'/one/level/above') #insert to make sure that forum will be found
115 sys.path.append('/one/level/above/OSQA') #maybe this is not necessary
116 os.environ['DJANGO_SETTINGS_MODULE'] = 'OSQA.settings'
117 import django.core.handlers.wsgi
118 application = django.core.handlers.wsgi.WSGIHandler()
121 insert method is used for path because if the forum directory name
122 is by accident the same as some other python module
123 you wull see strange errors - forum won't be found even though
124 it's in the python path. for example using name "test" is
125 not a good idea - as there is a module with such name
128 4.2 Configure webserver
129 Settings below are not perfect but may be a good starting point
132 WSGISocketPrefix /path/to/socket/sock #must be readable and writable by apache
133 WSGIPythonHome /usr/local #must be readable by apache
134 WSGIPythonEggs /var/python/eggs #must be readable and writable by apache
136 #NOTE: all urs below will need to be adjusted if
137 #settings.FORUM_SCRIPT_ALIAS !='' (e.g. = 'forum/')
138 #this allows "rooting" forum at http://example.com/forum, if you like
139 <VirtualHost ...your ip...:80>
140 ServerAdmin forum@example.com
141 DocumentRoot /path/to/osqa-site
142 ServerName example.com
144 #run mod_wsgi process for django in daemon mode
145 #this allows avoiding confused timezone settings when
146 #another application runs in the same virtual host
147 WSGIDaemonProcess OSQA
148 WSGIProcessGroup OSQA
150 #force all content to be served as static files
151 #otherwise django will be crunching images through itself wasting time
152 Alias /m/ /path/to/osqa-site/forum/skins/
153 Alias /upfiles/ /path/to/osqa-site/forum/upfiles/
154 <Directory /path/to/osqa-site/forum/skins>
159 #this is your wsgi script described in the prev section
160 WSGIScriptAlias / /path/to/osqa-site/osqa.wsgi
162 #this will force admin interface to work only
163 #through https (optional)
164 #"nimda" is the secret spelling of "admin" ;)
167 RewriteRule /nimda(.*)$ https://example.com/nimda$1 [L,R=301]
169 CustomLog /var/log/httpd/OSQA/access_log common
170 ErrorLog /var/log/httpd/OSQA/error_log
172 #(optional) run admin interface under https
173 <VirtualHost ..your ip..:443>
174 ServerAdmin forum@example.com
175 DocumentRoot /path/to/osqa-site
176 ServerName example.com
178 SSLCertificateFile /path/to/ssl-certificate/server.crt
179 SSLCertificateKeyFile /path/to/ssl-certificate/server.key
180 WSGIScriptAlias / /path/to/osqa-site/osqa.wsgi
181 CustomLog /var/log/httpd/OSQA/access_log common
182 ErrorLog /var/log/httpd/OSQA/error_log
183 DirectoryIndex index.html
187 5. Full text search (using sphinx search)
189 Currently full text search works only with sphinx search engine
190 And builtin PostgreSQL (postgres only >= 8.3???)
192 5.1 Instructions for Sphinx search setup
193 Sphinx at this time supports only MySQL and PostgreSQL databases
194 to enable this, install sphinx search engine and djangosphinx
196 configure sphinx, sample configuration can be found in
197 sphinx/sphinx.conf file usually goes somewhere in /etc tree
199 build osqa index first time manually
201 % indexer --config /path/to/sphinx.conf --index osqa
203 setup cron job to rebuild index periodically with command
204 your crontab entry may be something like
206 0 9,15,21 * * * /usr/local/bin/indexer --config /etc/sphinx/sphinx.conf --all --rotate >/dev/null 2>&1
207 adjust it as necessary this one will reindex three times a day at 9am 3pm and 9pm
209 if your forum grows very big ( good luck with that :) you'll
210 need to two search indices one diff index and one main
211 please refer to online sphinx search documentation for the information
212 on the subject http://sphinxsearch.com/docs/
214 in settings_local.py set
215 USE_SPHINX_SEARCH=True
216 adjust other settings that have SPHINX_* prefix accordingly
217 remember that there must be trailing comma in parentheses for
218 SHPINX_SEARCH_INDICES tuple - particlarly with just one item!
220 in settings.py look for INSTALLED_APPS
221 and uncomment #'djangosphinx',
224 6. Email subscriptions
226 This function at the moment requires Django 1.1
228 edit paths in the file cron/send_email_alerts
229 set up a cron job to call cron/send_email_alerts once or twice a day
230 subscription sender may be tested manually in shell
231 by calling cron/send_email_alerts
234 Sitemap will be available at /<settings_local.FORUM_SCRIPT_ALIAS>sitemap.xml
235 e.g yoursite.com/forum/sitemap.xml
237 google will be pinged each time question, answer or
238 comment is saved or a question deleted
240 for this to be useful - do register you sitemap with Google at
241 https://www.google.com/webmasters/tools/
245 There are some demo scripts under sql_scripts folder,
246 including badges and test accounts for CNProg.com. You
247 don't need them to run your sample.
249 C. CONFIGURATION PARAMETERS
251 #the only parameter that needs to be touched in settings.py is
252 DEBUG=False #set to True to enable debug mode
254 #all forum parameters are set in file settings_local.py
256 LOG_FILENAME = 'osqa.log' #where logging messages should go
257 DATABASE_NAME = 'osqa' # Or path to database file if using sqlite3.
258 DATABASE_USER = '' # Not used with sqlite3.
259 DATABASE_PASSWORD = '' # Not used with sqlite3.
260 DATABASE_ENGINE = 'mysql' #mysql, etc
262 DEFAULT_FROM_EMAIL = ''
264 EMAIL_HOST_PASSWORD = '' #not necessary if mailserver is run on local machine
265 EMAIL_SUBJECT_PREFIX = '[OSQA] '
266 EMAIL_HOST='osqa.com'
269 TIME_ZONE = 'America/Tijuana'
270 APP_TITLE = u'OSQA Q&A Forum' #title of your forum
271 APP_KEYWORDS = u'OSQA,forum,community' #keywords for search engines
272 APP_DESCRIPTION = u'Ask and answer questions.' #site description for searche engines
273 APP_INTRO = u'<p>Ask and answer questions, make the world better!</p>' #slogan that goes to front page in logged out mode
274 APP_COPYRIGHT = '' #copyright message
276 #if you set FORUM_SCRIPT_ALIAS= 'forum/'
277 #then OSQA will run at url http://example.com/forum
278 #FORUM_SCRIPT_ALIAS cannot have leading slash, otherwise it can be set to anything
279 FORUM_SCRIPT_ALIAS = '' #no leading slash, default = '' empty string
281 LANGUAGE_CODE = 'en' #forum language (see language instructions on the wiki)
282 EMAIL_VALIDATION = 'off' #string - on|off
283 MIN_USERNAME_LENGTH = 1
284 EMAIL_UNIQUE = False #if True, email addresses must be unique in all accounts
285 APP_URL = 'http://osqa.com' #used by email notif system and RSS
286 GOOGLE_SITEMAP_CODE = '' #code for google site crawler (look up google webmaster tools)
287 GOOGLE_ANALYTICS_KEY = '' #key to enable google analytics on this site
288 BOOKS_ON = False #if True - books tab will be on
289 WIKI_ON = True #if False - community wiki feature is disabled
291 #experimental - allow password login through external site
292 #must implement django_authopenid/external_login.py
293 #included prototype external_login works with Mediawiki
294 USE_EXTERNAL_LEGACY_LOGIN = True #if false OSQA uses it's own login/password
295 EXTERNAL_LEGACY_LOGIN_HOST = 'login.osqa.com'
296 EXTERNAL_LEGACY_LOGIN_PORT = 80
297 EXTERNAL_LEGACY_LOGIN_PROVIDER_NAME = '<span class="orange">OSQA</span>'
299 FEEDBACK_SITE_URL = None #None or url
300 LOGIN_URL = '/%s%s%s' % (FORUM_SCRIPT_ALIAS,'account/','signin/')
302 DJANGO_VERSION = 1.1 #must be either 1.0 or 1.1
303 RESOURCE_REVISION=4 #increment when you update media files - clients will be forced to load new version
307 Other than settings_local.py the following will most likely need customization:
308 * locale/*/django.po - language files that may also contain your site-specific messages
309 if you want to start with english messages file - look for words like "forum" and
310 "OSQA" in the msgstr lines
311 * templates/header.html and templates/footer.html may contain extra links
312 * templates/about.html - a place to explain for is your forum for
313 * templates/faq.html - put answers to users frequent questions
314 * templates/content/style/style.css - modify style sheet to add disctinctive look to your forum