WebFaction
Community site: login faq
0
2

I wrote a small shell script to install web2py (latest) with nginx (1.0.11) and uwsgi (1.0.2.1). I have tested it on three different accounts and it seems to work fine. I commented out the creation of the cronjobs, because I did not need them, so this is not tested. I hope that this will be useful to you :-)

I used the information form the following sites:

When I have more time, I will write a python version that works with the xml-rpc and can be used as a install script:

How to use the script:

  1. Log into the control panel

  2. Go to Domains/websites -> Applications

  3. Create a new "Custom App listening on port" named something like "nginx_uwsgi_web2py"

  4. Note the port from the creation of the "Custom App listening on port"

  5. SSH into your server and start the script from any directory (you will be prompted for the needed information)

  6. Be happy with your installation already running :-)

If you like the script, feel free to vote for it.

Here is the script:

#!/bin/sh

# TODO's:
# * find free port for communication for nginx and uwsgi
# * test conjob creation properly

echo 'Install script for nginx (1.0.11), uwsgi (1.0.2.1) and web2py (latest stable)'
echo 'If you wish to create cronjobs comment out the last lines of this script'

# port betweet nginx and uwsgi
nginx_uwsgi_port=9001

# Get web2py admin password
echo "Web2py admin password:"
read  web2py_password

# Get webfaction application name
echo "Webfaction application name:"
read  webfaction_app_name

# Get webfaction port number
echo "Webfaction application port:"
read  webfaction_app_port

# port betweet nginx and uwsgi
echo "Port number for communication between nginx and uswgi (eg. 9001):"
read nginx_uwsgi_port

### 
### web2py
###
cd ~/webapps/${webfaction_app_name}
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
rm web2py_src.zip
cd web2py
python -c "from gluon.main import save_password; save_password('${web2py_password}',443)"
cd ..

###
### nginx
###
mkdir downs
cd downs

# download and install nginx in the appname directory
wget http://nginx.org/download/nginx-1.0.11.tar.gz
tar xvf nginx-1.0.11.tar.gz
cd nginx-1.0.11

./configure \
  --prefix=/home/${USER}/webapps/${webfaction_app_name}/nginx \
  --sbin-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx \
  --conf-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf \
  --error-log-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/log/error.log \
  --pid-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid  \
  --lock-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/lock/nginx.lock \
  --with-http_gzip_static_module \
  --http-log-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/log/access.log \
  --http-client-body-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/client/ \
  --http-proxy-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/proxy/ \
  --http-fastcgi-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/fcgi/
make && make install
cd ..

# configure nginx
cd ..
mkdir nginx/tmp
mkdir nginx/tmp/client
cd nginx

echo "
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    access_log  /home/${USER}/logs/user/access_appname.log  combined;
    error_log   /home/${USER}/logs/user/error_appname.log   crit;

    include                mime.types;
    client_max_body_size   5m;
    default_type           application/octet-stream;
    gzip_static            on;
    gzip_vary              on;
    sendfile               on;
    tcp_nodelay            on;

    server {
        listen ${webfaction_app_port};
        location ~* /(\w+)/static/ {
            root /home/${USER}/webapps/${webfaction_app_name}/web2py/applications/;
        }
        location / {
            uwsgi_pass      127.0.0.1:${nginx_uwsgi_port};
            include         uwsgi_params;
        }
    }
}
" > nginx.conf

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid )
" > stop
chmod +x stop

# start nginx
./sbin/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf
cd ..

### 
### uwsgi
###
mkdir uwsgi
cd downs

# download and install uwsgi in the appname directory
wget http://projects.unbit.it/downloads/uwsgi-1.0.2.1.tar.gz
tar xvf uwsgi-1.0.2.1.tar.gz

cd uwsgi-1.0.2.1
make -f Makefile.Py26
cp uwsgi ../../uwsgi/

cd ../../uwsgi
echo "<uwsgi>
    <socket>127.0.0.1:${nginx_uwsgi_port}</socket>
    <workers>4</workers>
    <no-orphans/>
    <pythonpath>/home/${USER}/webapps/${webfaction_app_name}/web2py</pythonpath>
    <pidfile>/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid</pidfile>
    <daemonize>/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.log</daemonize>
    <app mountpoint=\"/\">
        <script>wsgihandler</script>
    </app>
</uwsgi>" > uwsgi.xml

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid )
" > stop
chmod +x stop

# start uwsgi
./uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml
cd ..

###
### cleanup
###
rm -rf downs

##
## create start/stop scripts
##
echo "#!/bin/sh
/home/${USER}/webapps/${webfaction_app_name}/nginx/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf
/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml
" > start
chmod +x start

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid )
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid )
" > stop
chmod +x stop

###
### create cronjobs
###

#nginx_cron="10,30,50 * * * * /home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf"
#(crontab -l; echo "$nginx_cron" ) | crontab -
# 
#uwsgi_cron="10,30,50 * * * * /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml"
#(crontab -l; echo "$uwsgi_cron" ) | crontab -

asked 24 Jan '12, 14:24

salomonderossi
3113
accept rate: 0%

edited 30 Jan '12, 16:21

Thanks for this :)

I am very sure that many of the other customers will find it useful.

(24 Jan '12, 19:47) neeravk

I am planning to use this script to install web2py which is currently running on a apache. I got few questions: 1. How to install the admin app and what will be its url? 2. In the current setup I got a crontab for start/restart of apache server. Is something similar needed (start/restart of the server)? 3. What does the commented crontab do?

Thanks a lot Joseph

(25 Jan '12, 10:38) Joseph Jude

My webfaction account is barely a couple of hours old and I'm a complete novice when it comes to unix, but with a bit of help from google I managed to run the script, apparently without errors. Files are in place. Now I find I haven't a clue what to do next. How do I connect to admin or welcome? Is it just a matter of entering the correct url or do I have to run something?

By the way, I'm full of admiration of you chaps with binary brains, and thanks very much for taking the trouble to make the script available. :o)

(07 Feb '12, 16:43) Edward

@Edward - you need to add your custom web2py app to a site in the our control panel, and you can then access it via whatever domain you've assigned to the site. If you need to access the admin, then be sure to enable HTTPS for your site. Hope that helps!

(07 Feb '12, 17:18) seanf

That worked..! Thank you :o)

Am learning fast... LOL

What a brilliant script. :o)

(08 Feb '12, 00:45) Edward

I had cause to stop and restart the server today and came across an error in the start script Luckily the script is only two lines long so even I didn't have too much trouble working out what was wrong. Anyway on the first line this .../nginx/nginx... should be replaced with this .../nginx/sbin/nginx...

(08 Feb '12, 15:57) Edward

Excellent work. Did you install libxml? I got a compile error: xmlconf.c:9:27: error: libxml/parser.h: No such file or directory

(08 Feb '12, 19:43) Baron

Hi Baron, if you are asking me? I didn't install anything beyond the script yet.

(08 Feb '12, 23:42) Edward

Ryan told me where to find libxml path: /usr/include/libxml2 Now got it working. Outstanding.

I found the start script generation part at line 154 needs to add the "sbin/" directory: /home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx

(09 Feb '12, 23:58) Baron

Just another heads up... You need to replace "443" in the line that saves the password file with your port number, otherwise you can't run admin. If you've already run the script you can simply rename the file. The file name is parameters_xxxx.py and can be found in the web2py directory.

Also the uwsgi stop script sometimes does not match the pid number saved. Don't know why?

(12 Feb '12, 08:22) Edward

A question about XML-RPC... regarding salomonderossi's comment above the script:

When I have more time, I will write a python version that works with the xml-rpc and can be used as a install script

Does this mean web2py's XMLRPC decorator (@service.xmlrpc) will not work as expected if we installed web2py using this script?

If so, is there a way to manually fix it? I'm worried I won't be able to figure it out myself if it involves customizing the behavior of nginx/uwsgi... Any help is appreciated :)

(03 Apr '12, 05:42) prole

prole: no, I don't think so. I believe salomonderossi meant that this script is not intended to use with Webfaction's xml-rpc API, and he is thinking of writing another script that would work with the API and can be used as an install script from the control panel.

(03 Apr '12, 05:58) todork

todork: You're right, web2py's XMLRPC works fine on WebFaction with this script. I just checked by testing a trivial XMLRPC call on my setup. I wanted to follow up instead of leaving any FUD floating around :)

For anyone interested in learning more, see:

  • http://web2py.com/books/default/chapter/29/10#XMLRPC
  • http://docs.python.org/library/xmlrpclib.html
(03 Apr '12, 06:44) prole

trying my best to get this working... everything installed correctly and appears to be running fine.. made the update outlined here about nginx/sbin/nginx but didnt find the paramaters_xxxx.py file... heres whats running:

    [thedrizzle@web150 web2py]$ ps -u thedrizzle -o rss,etime,pid,command                    
RSS ELAPSED PID COMMAND 3384 122-17:51:32 5499 /home/thedrizzle/webapps/web2py_test/apache2/bin/httpd -f /home/thedrizzle/webapps/web2py_test/apache2/conf/httpd.conf -k start 23808 122-17:51:32 5535 /home/thedrizzle/webapps/web2py_test/apache2/bin/httpd -f /home/thedrizzle/webapps/web2py_test/apache2/conf/httpd.conf -k start 23584 122-17:51:32 5536 /home/thedrizzle/webapps/web2py_test/apache2/bin/httpd -f /home/thedrizzle/webapps/web2py_test/apache2/conf/httpd.conf -k start 512 09:01 6014 nginx: master process /home/thedrizzle/webapps/nginx_uwsgi_web2py/nginx/sbin/nginx -c /home/thedrizzle/webapps/nginx_uwsgi_web2py/nginx/nginx. 696 09:01 6015 nginx: worker process
712 09:01 6016 nginx: worker process
12892 09:01 6019 /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi -x /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi.xml 9936 09:00 6033 /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi -x /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi.xml 9936 09:00 6034 /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi -x /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi.xml 9936 09:00 6036 /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi -x /home/thedrizzle/webapps/nginx_uwsgi_web2py/uwsgi/uwsgi.xml 1956 07:58 7091 sshd: thedrizzle@notty 1796 07:57 7096 /usr/libexec/openssh/sftp-server 908 00:00 12086 ps -u thedrizzle -o rss,etime,pid,command 1584 02:13:01 20922 sshd: thedrizzle@pts/0 1484 02:13:00 20923 -bash 1568 26:55 27328 sshd: thedrizzle@pts/10 1600 26:55 27329 -bash

anyone can help?

(14 Jun '12, 22:22) thedrizzle

That should be located in the web2py directory, which should be /home/thedrizzle/webapps/nginx_uwsgi_web2py/web2py in your case.

If the file doesn't exist, feel free to create it. Just change the xxxx part with the port you want.

(16 Jun '12, 11:30) iliasr ♦♦

got it thanks!

(04 Jul '12, 08:09) thedrizzle

What are the advantages of this over the Apache install script? Less resource usage?

(15 Oct '12, 22:11) HittingSmoke

It is a little faster and uses a little less resource. You would have to benchmark your code on both stacks to see exactly how much.

(15 Oct '12, 22:23) johns
showing 5 of 18 show 13 more comments

Thank you so much for this easy solution, salomonderossi!

I ran into only one problem: I went with the arbitrary port 9001 for communications between nginx and uwsgi. I guess someone else on my shared host used the same script, so the port was already in use. Maybe someone more familiar with the setup would've known immediately what the problem was, but all I was seeing when trying to load the web2py "welcome" app was the message: invalid request

I went back and changed port 9001 to another number in the two configuration files, nginx.conf and uwsgi.xml and stopped/started them again. It works :)

Thanks again for sharing your lovely script.

permanent link

answered 29 Jan '12, 04:18

prole
161
accept rate: 100%

Hi,

Yes, the port was probably used by someone else on the server. To make it cleaner, you can create another custom app (listening on port), just to reserve the port, and use that instead.

(29 Jan '12, 04:46) todork

Thank you for pointing that out. That is why the script asks for a port number. If someone knows how to get a free port number on the shell, I will add it to the script :-).

(30 Jan '12, 16:18) salomonderossi

uWSGI has native http support for some time now so nginx is no longer needed.

I was able to get a vanilla web2py instance up and running using uwsgi doing the following:

Create a "Custom app (listening on port)" type of application using the control panel and noted the assigned port down.

Logged into the server via SSH.

Downloaded the web2py source, unziped it and copied everything to the app directory...

wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cp -R web2py/* ~/webapps/MY-WEB2PY-APP

... where MY-WEB2PY-APP is the name of the custom application I created earlier.

Installed uwsgi using pip.

Changed into the app directory and created my admin password...

cd ~/webapps/MY-WEB2PY-APP
python2.7 -c "from gluon.main import save_password; save_password('MY-PASSWORD',MY-PORT)

... where MY-PASSWORD is the admin password I wanted to use and MY-PORT the port I got assigned from the control panel.

I also copied the wsgihandler.py file to the root of the app (the dot is needed):

cp handlers/wsgihandler.py .

Finally I created a file named web2py.ini with the following content taken from the official documentation:

[uwsgi]
http = :MY-PORT
chdir = /home/MY-USERNAME/webapps/MY-WEB2PY-APP
module = wsgihandler
master = true

I then launched the app:

uwsgi web2py.ini

Please check uwsgi --help or the official documentation on how to daemonize the process, write logs to a file, etc.

permanent link

answered 11 Jan '15, 14:52

iliasr ♦♦
2.1k14
accept rate: 35%

edited 11 Jan '15, 15:11

To Anwer some questions:

  • The admin app will be installed by default with web2py. You have to give a password to the install script. The url depends on your webfaction configuration.
  • Webfaction supports long-running processes. Therefore it is not needed to start your processes via crontab. The last 5 lines of the script should add the start scripts for nginx and uwsgi in the crontab. The script is executed every hour on every day, at 10, 30 and 50 minute. It tries to start nginx and uwsgi. If they are already running in the same configuration the script failed (with port in use error) and nothing happens.

I hope I could help a little bit :-)

permanent link

answered 26 Jan '12, 09:15

salomonderossi
3113
accept rate: 0%

I cant get this to work, i ran the script and it did not give any errors. I can see my application listening to the custom port, my domain names are listed under the websites. Am I supposed to start the server in ssh? Sorry, I am completely new to linux and servers.

permanent link

answered 13 Apr '12, 22:43

chawk
1
accept rate: 0%

Submit a support ticket so we can look at the account.

(13 Apr '12, 23:05) johns

wget http://nginx.org/download/nginx-1.0.11.tar.gz is outdated, latest is 1.2.3

I changed to 1.2.3 in the script, but it failed at "make -f Makefile.Py26"

I changed this to just "make", but then on running uwsgi can't find python.

Please help.

permanent link

answered 07 Jun '12, 01:54

JohnB
1
accept rate: 0%

If the make command is not working for you, you could try pythonX.Y uwsgiconfig.py --build or pip-X.Y install wsgi, where X is the major and Y the minor number of python you want to use.

For further assistance you can check our Installing python packages and uWSGI installation's pages

(07 Jun '12, 06:03) iliasr ♦♦

I tried replacing 'make -f Makefile.Py26' with 'pythonX.Y uwsgiconfig.py --build' and the script finished but I still get "uWSGI Error: Python application not found"

(16 Dec '12, 18:38) HittingSmoke

@HittingSmoke maybe give the steps for installing uwsgi from this post a try.

(16 Dec '12, 18:51) bmeyer71 ♦♦

@bmeyer71 I actually got it working. Makefile.Py26 is now just Makefile. After fixing the file name and a few other issues it ran fine. I posted the updated script I used below in an answer.

(16 Dec '12, 20:28) HittingSmoke

Note that the uwsgi file no longer exists: http://projects.unbit.it/downloads/uwsgi-1.0.2.1.tar.gz

Also now need to copy wsgihandlers.py from handlers directory.

That is far as I got then get this error: uWSGI Error

Python application not found

(11 Jan '15, 10:11) Baron

Please provide all the options you pass to your uwsgi command and the lines above that 'python application not found` error you mention, so we can check for any errors or misconfigurations.

P.S. I've just written another way to deploy web2py with uwsgi. Feel free to give that a look.

(11 Jan '15, 15:10) iliasr ♦♦
showing 5 of 6 show 1 more comments

I've been trying to get this running with the latest versions of nginx and uwsgi for the last couple hours. After a lot of toubleshooting I've come up with an udpated script that works. It fixes some issues with the original script and brings the config entries up to date for the newer nginx and uwsgi versions. The result is noticeably faster response time over the apache web2py script on the wiki. After I toy around with nginx and uwsgi a bit more I'll tweak it for the optimal performance within default RAM allowances.

Changes:

  • Updated download links for newest stable nginx and uwsgi versions

  • make -f Makefile.Py26 changed to make -f Makefile to reflect latest uwsgi source filenames.

  • Added port number variable to the password line per Edward's tip.

  • Updated uwsgi.xml for web2py as per current instructions at https://projects.unbit.it/uwsgi/wiki/Example

  • Fixed incorrect path /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx in start script to home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx

WARNING: I AM NOT PROGRAMMER OR A SKILLED SYSADMIN. I MODIFIED THIS SCRIPT THROUGH TRIAL AND ERROR AND LOTS OF GOOGLING. REVIEW ALL COMMANDS YOURSELF BEFORE RUNNING IT AND ETC ETC!

#!/bin/sh

# TODO's:
# * find free port for communication for nginx and uwsgi
# * test conjob creation properly

echo 'Install script for nginx (1.2.6), uwsgi (1.4.3) and web2py (latest stable)'
echo 'If you wish to create cronjobs comment out the last lines of this script'

# port betweet nginx and uwsgi
nginx_uwsgi_port=9001

# Get web2py admin password
echo "Web2py admin password:"
read  web2py_password

# Get webfaction application name
echo "Webfaction application name:"
read  webfaction_app_name

# Get webfaction port number
echo "Webfaction application port:"
read  webfaction_app_port

# port betweet nginx and uwsgi
echo "Port number for communication between nginx and uswgi (eg. 9001):"
read nginx_uwsgi_port

### 
### web2py
###
cd ~/webapps/${webfaction_app_name}
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
rm web2py_src.zip
cd web2py
python -c "from gluon.main import save_password; save_password('${web2py_password}',${webfaction_app_port})"
cd ..

###
### nginx
###
mkdir downs
cd downs

# download and install nginx in the appname directory
wget http://nginx.org/download/nginx-1.2.6.tar.gz
tar xvf nginx-1.2.6.tar.gz
cd nginx-1.2.6

./configure \
  --prefix=/home/${USER}/webapps/${webfaction_app_name}/nginx \
  --sbin-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx \
  --conf-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf \
  --error-log-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/log/error.log \
  --pid-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid  \
  --lock-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/lock/nginx.lock \
  --with-http_gzip_static_module \
  --http-log-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/log/access.log \
  --http-client-body-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/client/ \
  --http-proxy-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/proxy/ \
  --http-fastcgi-temp-path=/home/${USER}/webapps/${webfaction_app_name}/nginx/tmp/fcgi/
make && make install
cd ..

# configure nginx
cd ..
mkdir nginx/tmp
mkdir nginx/tmp/client
cd nginx

echo "
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    access_log  /home/${USER}/logs/user/access_appname.log  combined;
    error_log   /home/${USER}/logs/user/error_appname.log   crit;

    include                mime.types;
    client_max_body_size   5m;
    default_type           application/octet-stream;
    gzip_static            on;
    gzip_vary              on;
    sendfile               on;
    tcp_nodelay            on;

    server {
        listen ${webfaction_app_port};
        location ~* /(\w+)/static/ {
            root /home/${USER}/webapps/${webfaction_app_name}/web2py/applications/;
        }
        location / {
            uwsgi_pass      127.0.0.1:${nginx_uwsgi_port};
            include         uwsgi_params;
        }
    }
}
" > nginx.conf

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid )
" > stop
chmod +x stop

# start nginx
./sbin/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf
cd ..

### 
### uwsgi
###
mkdir uwsgi
cd downs

# download and install uwsgi in the appname directory
wget http://projects.unbit.it/downloads/uwsgi-1.4.3.tar.gz
tar xvf uwsgi-1.4.3.tar.gz

cd uwsgi-1.4.3
make -f Makefile
cp uwsgi ../../uwsgi/

cd ../../uwsgi
echo "<uwsgi>
    <socket>127.0.0.1:${nginx_uwsgi_port}</socket>
    <workers>4</workers>
    <no-orphans/>
    <pythonpath>/home/${USER}/webapps/${webfaction_app_name}/web2py</pythonpath>
    <pidfile>/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid</pidfile>
    <daemonize>/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.log</daemonize>
    <module>wsgihandler</module>
    <master/>
    <memory-report/>
</uwsgi>" > uwsgi.xml

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid )
" > stop
chmod +x stop

# start uwsgi
./uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml
cd ..

###
### cleanup
###
rm -rf downs

##
## create start/stop scripts
##
echo "#!/bin/sh
/home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf
/home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml
" > start
chmod +x start

echo "#!/bin/sh
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.pid )
kill -s QUIT \$( cat /home/${USER}/webapps/${webfaction_app_name}/nginx/run/nginx.pid )
" > stop
chmod +x stop

###
### create cronjobs
###

#nginx_cron="10,30,50 * * * * /home/${USER}/webapps/${webfaction_app_name}/nginx/sbin/nginx -c /home/${USER}/webapps/${webfaction_app_name}/nginx/nginx.conf"
#(crontab -l; echo "$nginx_cron" ) | crontab -
# 
#uwsgi_cron="10,30,50 * * * * /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi -x /home/${USER}/webapps/${webfaction_app_name}/uwsgi/uwsgi.xml"
#(crontab -l; echo "$uwsgi_cron" ) | crontab -
permanent link

answered 16 Dec '12, 20:27

HittingSmoke
4822030
accept rate: 8%

edited 16 Dec '12, 20:35

Updated script is working just great! Thank you.

(25 Dec '12, 02:15) sabbir

Just ran the script at the bottom of the page. It seems to have worked without any errors. Accessing my domain brings me to web2py's welcome page. When I try to log in as admin, nothing happens - the server simply presents the same welcome page (the password is correct, as no password error message is presented). Any ideas on what could be going wrong?

(21 May '13, 10:44) will_ca

will_ca, that's a security feature of web2py. You must log in to the admin console via SSL.

You have to create a second website in your Webfaction panel with security enabled (Encrypted website (https)). Other than that configure it the same as your original web2py website. Then return to the admin login page and change "HTTP" to "HTTPS" in the address bar. That will allow you to log in.

(21 May '13, 10:57) HittingSmoke

I added the https entry point, and it works. Thank you!

(21 May '13, 11:06) will_ca

Here's a one-click install for web2py served with Nginx and uwsgi: web2py + nginx + uwsgi installer for WebFaction

Enjoy!

permanent link

answered 07 May '15, 01:11

seanf
12.2k31836
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×102
×24
×17

question asked: 24 Jan '12, 14:24

question was seen: 16,846 times

last updated: 07 May '15, 01:11

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM