PageRenderTime 32ms CodeModel.GetById 25ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/zope-quickstart.txt

https://bitbucket.org/ianb/silverlining/
Plain Text | 306 lines | 229 code | 77 blank | 0 comment | 0 complexity | 00e344ee259e8f147ed2681d5159c5a3 MD5 | raw file
  1Zope2 Quickstart
  2================
  3
  4Because we will have binary eggs that are OS architecture specific, we need to build everything on the same
  5type of machine that we are going to deploy to.
  6
  7Install silverlining on a Rackspace Cloud machine running Ubuntu Lucid::
  8
  9    $ cd /opt
 10    $ virtualenv -p python2.6 silverlining
 11    $ silverlining/bin/pip install -r http://bitbucket.org/ianb/silverlining/raw/tip/requirements.txt
 12    $ alias silver="/root/silverlining/bin/silver"
 13
 14Make an SSH key::
 15
 16    $ ssh-keygen
 17    Generating public/private rsa key pair.
 18    Enter file in which to save the key (/root/.ssh/id_rsa):
 19    Created directory '/root/.ssh'.
 20    Enter passphrase (empty for no passphrase):
 21    Enter same passphrase again:
 22    Your identification has been saved in /root/.ssh/id_rsa.
 23    Your public key has been saved in /root/.ssh/id_rsa.pub.
 24    The key fingerprint is:
 25    39:97:02:d0:57:d7:2e:fa:9c:63:92:18:6c:b7:7e:df root@silverlining
 26    The key's randomart image is:
 27
 28Set up the Rackspace authentication details::
 29
 30    $ silver
 31    /root/.silverlining.conf doesn't exists; let's create it
 32    Creating /root/.silverlining.conf
 33    Your service-provider username: jazkarta
 34    Your service-provider API key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 35    Using /root/.ssh/id_rsa.pub
 36
 37Initialize the application::
 38
 39    $ silver init zope-on-wsgi
 40    Using real prefix '/Users/nateaune/code/python/parts/opt'
 41    New python executable in zope-on-wsgi/bin/python
 42    Installing setuptools.............done.
 43
 44
 45Edit the setup.py to install some additional eggs
 46-------------------------------------------------
 47
 48Check out Tres' branch of the Zope2 with WSGI support::
 49
 50    $ cd zope-on-wsgi/src
 51    $ svn co http://svn.zope.org/repos/main/Zope/branches/tseaver-fix_wsgi Zope2
 52
 53Edit the file src/Zope2/setup.py, and add these lines to the install_requires section::
 54
 55    install_requires=[
 56        ...
 57        'zope.app.testing',
 58        'repoze.who',
 59        'repoze.retry',
 60        'repoze.tm2',
 61        'Paste',
 62        'PasteScript',
 63        'PasteDeploy',
 64        ],
 65
 66Install Zope2
 67-------------
 68
 69Use pip to install Zope2::
 70
 71    $ cd zope-on-wsgi
 72    $ source bin/activate
 73    (zope-on-wsgi)$ pip install -e src/Zope2
 74    ...
 75    Successfully installed Acquisition DateTime docutils ExtensionClass five.formlib initgroups mechanize Missing MultiMapping Paste PasteScript Persistence pytz Record repoze.retry repoze.tm2 repoze.who RestrictedPython tempstorage ThreadLock transaction zc.lockfile ZConfig zdaemon zLOG ZODB3 zope.annotation zope.app.appsetup zope.app.debug zope.app.dependable zope.app.form zope.app.publication zope.app.publisher zope.app.schema zope.app.testing zope.authentication zope.broken zope.browser zope.browsermenu zope.browserpage zope.browserresource zope.component zope.componentvocabulary zope.configuration zope.container zope.contentprovider zope.contenttype zope.datetime zope.deferredimport zope.dottedname zope.error zope.event zope.exceptions zope.filerepresentation zope.formlib zope.i18n zope.i18nmessageid zope.interface zope.lifecycleevent zope.location zope.minmax zope.mkzeoinstance zope.pagetemplate zope.password zope.processlifetime zope.proxy zope.ptresource zope.publisher zope.schema zope.security zope.sendmail zope.sequencesort zope.session zope.site zope.size zope.structuredtext zope.tal zope.tales zope.testbrowser zope.testing zope.traversing zope.viewlet Zope2 ZopeUndo
 76    Cleaning up...
 77
 78Make a Zope instance
 79--------------------
 80
 81You need to make a Zope instance::
 82
 83    $ cd zope-on-wsgi
 84    $ ./bin/mkzopeinstance
 85    Please choose a directory in which you'd like to install
 86    Zope "instance home" files such as database files, configuration
 87    files, etc.
 88
 89    Directory: .
 90    Please choose a username and password for the initial user.
 91    These will be the credentials you use to initially manage
 92    your new Zope instance.
 93
 94    Username: admin
 95    Password:
 96    Verify password:
 97
 98Make a Zope2 admin user
 99-----------------------
100
101You need to make a Zope2 admin user so that you can login to the instance::
102
103    $ ./bin/mkzope2user admin admin
104
105Make a zope.conf file
106---------------------
107
108Move the original zope.conf file out of the way::
109
110    $ cd zope-on-wsgi/etc
111    $ mv zope.conf zope.conf.orig
112
113Edit the zope.conf file to look like this::
114
115    %define INSTANCE <TODO: find out how to use a relative path>
116    instancehome $INSTANCE
117
118    effective-user www-mgr
119
120    <zodb_db main>
121        <filestorage>
122          path $INSTANCE/var/Data.fs
123        </filestorage>
124        mount-point /
125    </zodb_db>
126
127    <zodb_db temporary>
128        <temporarystorage>
129          name temporary storage for sessioning
130        </temporarystorage>
131        mount-point /temp_folder
132        container-class Products.TemporaryFolder.TemporaryContainer
133    </zodb_db>
134
135Make sure the www-data user owns the directory
136----------------------------------------------
137
138If you set the effective-user to "www-data", then you need to make sure that
139this user has ownership of the directory.
140
141    $ chown -R www-data:www-data zope-on-wsgi
142
143
144Make the WSGI configuration
145---------------------------
146
147Create a file zope-on-wsgi/etc/zope2.ini::
148
149    [DEFAULT]
150    debug = True
151
152    [app:zope]
153    use = egg:Zope2#main
154    zope_conf = %(here)s/zope.conf
155
156    [filter:who]
157    use = egg:repoze.who#config
158    config_file = %(here)s/who.ini
159
160    [pipeline:main]
161    pipeline =
162        egg:paste#evalerror
163        who
164        egg:repoze.retry#retry
165        egg:repoze.tm2#tm
166        zope
167
168    [server:main]
169    use = egg:paste#http
170    host = 0.0.0.0
171    port = 8080
172
173Add the who.ini and passwd file
174-------------------------------
175
176Add the file etc/who.ini::
177
178    [plugin:auth_tkt]
179    # identification and authentication
180    use = repoze.who.plugins.auth_tkt:make_plugin
181    secret = s33kr1t
182    cookie_name = oatmeal
183    secure = False
184    include_ip = False
185
186    [plugin:basicauth]
187    # identification and challenge
188    use = repoze.who.plugins.basicauth:make_plugin
189    realm = 'sample'
190
191    [plugin:htpasswd]
192    # authentication
193    use = repoze.who.plugins.htpasswd:make_plugin
194    filename = %(here)s/passwd
195    #check_fn = repoze.who.plugins.htpasswd:crypt_check
196    check_fn = repoze.who.plugins.htpasswd:plain_check
197
198    [general]
199    request_classifier = repoze.who.classifiers:default_request_classifier
200    challenge_decider = repoze.who.classifiers:default_challenge_decider
201    remote_user_key = REMOTE_USER
202
203    [identifiers]
204    # plugin_name;classifier_name:.. or just plugin_name (good for any)
205    plugins =
206            auth_tkt
207            basicauth
208
209    [authenticators]
210    # plugin_name;classifier_name.. or just plugin_name (good for any)
211    plugins =
212            auth_tkt
213            htpasswd
214
215    [challengers]
216    # plugin_name;classifier_name:.. or just plugin_name (good for any)
217    plugins =
218            basicauth
219
220    [mdproviders]
221    plugins =
222
223And add a password file etc/passwd::
224
225    admin:admin
226
227Test it with paster
228-------------------
229
230Fire up the WSGI app using paster to make sure it works locally::
231
232    (zope-on-wsgi)$ paster serve etc/zope2.ini
233    No handlers could be found for logger "root"
234    Starting server in PID 3742.
235    serving on 0.0.0.0:8080 view at http://127.0.0.1:8080
236
237Go to http://zope-on-wsgi to see your Zope site.
238
239Set up the WSGI runner
240----------------------
241
242Edit the zope-on-wsgi/app.ini file to point to the zope2.ini file you just created.
243Replace the <insert your runner here> with etc/zope2.ini.
244
245    [production]
246    app_name = zope-on-wsgi
247    ## Uncomment these to make them available:
248    #service.postgis =
249    #service.files =
250    #service.couchdb =
251    #service.mongodb =
252
253    runner = etc/zope2.ini
254    ## Uncomment to have /url called each time the app is updated:
255    # update_fetch = /url
256    ## If you always upload this app to a particular hostname, use this:
257    #default_host = ...
258    packages = python-setuptools
259
260Try serving the app using silverlining
261--------------------------------------
262
263You can start the app using silverlining with this command::
264
265    $ silver serve zope-on-wsgi
266    No handlers could be found for logger "root"
267    serving on http://127.0.0.1:8080
268
269Since it's being served on 127.0.0.1, you won't be able to see it in the browser, unless you open it up on the same machine you're running it from.
270
271Create the server node
272----------------------
273
274    # silver create-node wsgify --setup-node
275    Creating node (image=Ubuntu 10.04 LTS (lucid); size=256 server)
276    Status 3 at IP 174.143.146.185
277    The hostname/ip is not setup in /etc/hosts
278    Would you like me to set it up?  [y/n] y
279    Executing sudo python /opt/silverlining/src/silverlining/silverlining/update_etc_hosts.py /etc/hosts 174.143.146.185 wsgify
280    Waiting for server to be ready....Server created (1:01 to create)
281    Waiting 10 seconds for full boot
282    Setting up server
283    Setting up authentication on server...
284    Using key file:  /root/.ssh/id_rsa.pub
285    Warning: Permanently added 'wsgify,174.143.146.185' (RSA) to the list of known hosts.
286    root@wsgify's password:
287    (check your email for the password)
288    Updating indexes and setting up rsync
289    ...
290    Copying files from `/etc/skel' ...
291    Restarting apache2 and varnish
292
293Update the server with your app
294-------------------------------
295
296Run this command to rsync the changes locally with the remote server::
297
298    $ silver update --node=wsgify zope2-on-wsgi
299
300Now go to http://zope2-on-wsgi/ to see the Zope application running.
301You might have to add an entry to your local /etc/hosts file (on your Mac).
302
303Troubleshooting
304---------------
305
306If you get WSGI error messages, look at the log file in: /var/log/silverlining/apps/zope-on-wsgi/errors.log