Are you committed to Cherokee? I would advise against that since 
development has stalled/stopped and instead consider Apache or Nginx. If 
Nginx, web2py includes a setup script:
http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

You can either run the script as-is or, a better idea is to just manually 
run each step so you get an understanding for what's going on and can fix 
any problems.



On Thursday, June 7, 2012 11:50:06 AM UTC-7, Leopold wrote:
>
> Hello everyone, I'm in need of help to get this configuration (ubuntu + 
> cherokee + web2py + uwsgi) running.
> I used a very similar how to on this (this happened many months ago) and 
> everything worked perfectly.
>
> When I followed the instructions I had an ubuntu version with python 2.6 
> but when I decided to upgrade to ubuntu 12.04 (python 2.7) the problem 
> started. Initially the problem was the 503 Service Unavailable message and 
> by looking at the logs it was obvious the change in python version was 
> responsible for this since uwsgi was saying libpython2.6.so.1.0 missing or 
> something like that. So I reinstalled the latest uwsgi built with python 
> 2.7 and the 503 error went away. However I still couldn't get my web2py app 
> to show, I now get:
>
> *uWSGI Error*Python application not found
>
> I searched all over for this but I can't find how to fix it. I'm posting 
> the cherokee error log and the uwsgi config file hoping you can help me.
>
>
> # cat /var/log/cherokee/cherokee.error
> [uWSGI] parsing config file /var/web2py/config.xml
> [WARNING] option "app" is deprecated: use the more advanced "mount" option
> *** Starting uWSGI 1.2.3 (32bit) on [Thu Jun  7 11:19:17 2012] ***
> compiled with version: 4.6.3 on 07 June 2012 09:24:31
> detected number of CPU cores: 1
> current working directory: /
> detected binary path: /usr/bin/uwsgi
> *** WARNING: you are running uWSGI without its master process manager ***
> your memory page size is 4096 bytes
> detected max file descriptor number: 1024
> lock engine: pthread robust mutexes
> uwsgi socket 0 bound to TCP address 127.0.0.1:40890 fd 4
> Python version: 2.7.3 (default, Apr 20 2012, 23:06:40)  [GCC 4.6.3]
> *** Python threads support is disabled. You can enable it with 
> --enable-threads ***
> Python main interpreter initialized at 0x896f8a0
> your server socket listen backlog is limited to 100 connections
> *** Operational MODE: single process ***
> added /var/web2py/ to pythonpath.
> mounting wsgihandler on /
> *** no app loaded. going in full dynamic mode ***
> *** uWSGI is running in multiple interpreter mode ***
> spawned uWSGI worker 1 (and the only) (pid: 7903, cores: 1)
> [pid: 7903|app: -1|req: -1/1] 192.1.209.75 () {54 vars in 875 bytes} [Thu 
> Jun  7 11:19:17 2012] GET /favicon.ico => generated 48 bytes in 0 msecs 
> (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
> [pid: 7903|app: -1|req: -1/2] 192.1.209.75 () {56 vars in 922 bytes} [Thu 
> Jun  7 11:20:01 2012] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 
> 2 headers in 63 bytes (0 switches on core 0)
> [pid: 7903|app: -1|req: -1/3] 192.1.209.75 () {54 vars in 875 bytes} [Thu 
> Jun  7 11:20:01 2012] GET /favicon.ico => generated 48 bytes in 0 msecs 
> (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
> [pid: 7903|app: -1|req: -1/4] 192.1.209.75 () {54 vars in 891 bytes} [Thu 
> Jun  7 11:20:09 2012] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 
> 2 headers in 63 bytes (0 switches on core 0)
> [pid: 7903|app: -1|req: -1/5] 192.1.209.75 () {54 vars in 875 bytes} [Thu 
> Jun  7 11:20:09 2012] GET /favicon.ico => generated 48 bytes in 0 msecs 
> (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
>
>
> # cat /var/web2py/config.xml
> <uwsgi>
>     <pythonpath>/var/web2py/</pythonpath>
>     <app mountpoint="/">
>     <script>wsgihandler</script>
>     </app>
> </uwsgi>
>
> cherokee interpreter:
> /usr/bin/uwsgi -s 127.0.0.1:40890 -x /var/web2py/config.xml
>
>
> Thanks in advance.
>
> On Thursday, January 14, 2010 2:14:09 PM UTC-8, Ivan P wrote:
>>
>> Inspired by Phyo Arkar's howto on setting up web2py with Cherokee and
>> FCGI I tried the setup, but was somewhat unsatisfied with the fcgi
>> method and decided to try uWSGI. I am happy I did so, since it proved
>> to be real easy and uWSGI is a real powerhouse and deserves attention
>> of the whole python webdev community. On to the howto.
>>
>> I. Compile from source and run the latest uWSGI, 0.9.3 in my case
>> (available here http://projects.unbit.it/uwsgi/wiki).
>> 1. Download the source from and unzip.
>>
>> 2. To compile you must install packages python-dev and libxml2-dev (at
>> least thats what they are called on a debian-based system)
>>
>> 3. When compiling simply run pick a makefile which matches your OS and
>> python version and run something like "make -f Makefile.Linux.Py26".
>> This produces only one executable named uwsgi26, where 26 is my python
>> version. You can put it in /usr/local/bin.
>>
>> 5. To run it, you have two options:
>>
>> 5a) Create an xml file and call it, for example, config.xml. Put
>> something like this in it:
>> <uwsgi>
>>     <pythonpath>/var/web2py/</pythonpath>
>>     <app mountpoint="/">
>>     <script>wsgihandler</script>
>>     </app>
>> </uwsgi>
>> In this file "pythonpath" is where your web2py directory is and
>> "script" is the file you want to run, in this case its web2py's
>> "wsgihandler.py". Now run uWSGI like this, but replace "www-data" with
>> the owner of your web2py directory, if its the same as your current
>> user omit the sudo command:
>> sudo -u www-data uwsgi26 -s /tmp/uwsgi.sock -C -x config.xml
>> Why you need to change user is because web2py writes things (session
>> data for example) to disc during execution, so the uwsgi process,
>> which runs the web2py code, has to be the owner of the directories
>> that contain the framework. Note that uwsgi now opened a socket we
>> called "/tmp/uwsgi.sock" About other options consult the uwsgi manual
>> or "uwsgi -h".
>>
>> 5b) You can omit the xml file and pass all the info via command line,
>> doing that is easy, so consult the uwsgi docs :)
>>
>>
>> II. Setting up cherokee (0.99.37 in my case).
>> 1. Install it, run cherokee-admin, go to localhost:9090
>>
>> 2. Open "Information Sources" and create a new one with these
>> parameters:
>> Nick: web2py
>> Connection: /tmp/uwsgi.sock
>> Interpreter: uwsgi26 -s /tmp/uwsgi.sock -C -x /path/to/config.xml
>> The interpreter line is why it is a good idea to have your web2py
>> source owned by www-data or the Cherokee server's user - when cherokee
>> runs it, you can be sure that owners of the sources and process match.
>> And of  course put the correct path in.
>>
>> 3. Go to "Virtual Servers" and edit the default one, or you can create
>> a new one, but make sure you give it a domain name to avoid conflict
>> (not really sure what happens when they conflict).
>>
>> 4. Go to the "Behavior" section and edit the "Default" behavior.
>>
>> 5. Set the "Handler" to uWSGI and on the bottom set the information
>> source to "web2py"
>>
>> 6. Pick "Hard restart" from the dropdown on the left and click "Save".
>> TO PREVENT HEADACHE READ THIS: I seem to get inconsistent results with
>> these restarts, so if you're doing production it seems to me that one
>> should restart the server manualy (via /etc/init.d/cherokee restart,
>> that is). Or maybe I should RTFM.
>>
>> 6. Go to localhost and BAM! (or at least I hope its a bam). veeery
>> easy if all goes smooth.
>>
>> "But wait, what about url rewriting?" was my thought, and this caused
>> much confusion, so I'll add a section on that.
>>
>>
>> III. Doing some redirection (I'll give few examples due to poor
>> knowledge of regex).
>> Lets redirect "localhost/" to "/myapp/cntrlr/index"
>> 1. Go back to the "Behavior" section of your server.
>>
>> 2. Add a new rule and set it's type to "Regular Expression" and set
>> the regular expression to "^/$", this simply matches "localhost/" or
>> "localhost", nothing more, nothing less.
>>
>> 3. Go to the "Handler" section and set the rule to "Redirect" with
>> these parameters
>> Type: Internal
>> Regular Expression:     (yes, blank)
>> Substitution: /myapp/cntrlr/index
>> The regular expression is blank because for this scenario we did all
>> the matching while defining a new behavior, you can combine the two in
>> creative ways.
>>
>> That's about all. Your imagination should take care of the rest. I,
>> for example, put my static files separately from the framework by
>> creating a behavior that points to "/static" and picking "static
>> files" as the handler.
>> Thanks to Massimo DiPierro for web2py and Phyo Arkar for his cherokee
>> howto.
>> I'm not much of a writer so feel free to ask for clarifications.
>>
>>

Reply via email to