2

I was trying to deploy Plone 5 with WSGI and FastCGI. Based on a link on official Plone 5 document, Plone 5 supports deployment with WSGI. I can successfully run bin/paste serve zope.wsgi based on the link above, and see the Plone 5 home page.

The next step is wrapping the WSGI application with flup, which make it compatible with FastCGI. I created two files:

dispatch_fcgi.py:

#!/usr/bin/env python
ve = '/home/xxx/Plone/zinstance'

import site
site.addsitedir(ve+'/eggs')

from flup.server.fcgi import WSGIServer
from paste.deploy import loadapp

wsgi_app = loadapp('config:'+ve+'/zope.wsgi')

if __name__ == '__main__':
    WSGIServer(wsgi_app).run()

and

dispatch.fcgi:

#!/bin/bash
this_dir=`dirname $0`

export HOME=/home/xxx
source "$HOME/Plone/zinstance/bin/activate"

err_log_file="${this_dir}/../logs/dispatch_err.log"
exec python "${this_dir}/dispatch_fcgi.py" "$@" 2>>"${err_log_file}"

.htaccess redirects all requests to dispatch.fcgi, which set up all environments and pass arguments to dispatch_fcgi.py. The latter one then load the WSGI configuration file with Paste, and run it.

Ideally, it should run exactly the same as running with ./bin/paste serve zope.wsgi. However, it shows me the default Zope page, and I cannot access ZMI because it keeps asking me for password (I can access it with paste serve). Also, the URL is weird, like 'http://xxxxxx/dispatch.fcgi/manage', where dispatch.fcgi should not be a part of it.

Any idea why the behaviour is different when executing ./bin/paste serve zope.wsgi and running paste inside a script?

UPDATE: .htaccess

Options +ExecCGI
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule   ^(dispatch\.fcgi/.*)$  - [QSA,L]
RewriteRule   ^(.*)$  dispatch.fcgi/$1 [QSA,L]
Lingfeng Xiong
  • 1,131
  • 2
  • 9
  • 25
  • What webserver are you using? What does your `apache.conf` or `httpd.conf` file look like where you configure fcgi? What's in your `.htaccess` file? What do your app's error logs and Apache error logs say? – Mark Mikofski Sep 17 '16 at 22:44
  • @MarkMikofski I don't have access to `apache.conf`, but it allows all override. `.htaccess` is attached in my original question. – Lingfeng Xiong Sep 18 '16 at 02:06
  • Please provide tail of both error logs – Mark Mikofski Sep 18 '16 at 02:16
  • @MarkMikofski Both logs (`error.log` from apache and `dispatch_err.log` for fcgi) are empty. I think this is correct because it shows me the default Zope page, titled as 'Zope Quick Start ', which is not an error page, and no error occurred. However, it is expected to show me the home page of `Plone`, like `paste serve` did. – Lingfeng Xiong Sep 18 '16 at 19:02
  • Apache access log? – Mark Mikofski Sep 18 '16 at 19:29
  • @MarkMikofski Very common staffs... `x.x.x.x - - [18/Sep/2016:11:58:07 -0700] "GET / HTTP/1.1" 200 1172 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:48.0) Gecko/20100101 Firefox/48.0" x.x.x.x - - [18/Sep/2016:11:58:25 -0700] "GET /manage_page_style.css HTTP/1.1" 200 795 "http://xxxx.xxx/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:48.0) Gecko/20100101 Firefox/48.0" ` – Lingfeng Xiong Sep 18 '16 at 19:40
  • Try replacing the 3rd line in your `.htaccess` with `RewriteCond "%{REQUEST_FILENAME}" !-f` this will make sure you can't use `dispatch.fcgi` in your URL – Mark Mikofski Sep 18 '16 at 22:45
  • @MarkMikofski No help. I think the "`dispatch.fcgi` in url" problem is caused by the Zope framework incorrectly recognize the base URL, so it generated weird links. Nothing to do with `.htaccess`. – Lingfeng Xiong Sep 25 '16 at 05:10

0 Answers0