Create uWSGI switch command.
'#! / Bin / sh
'# Autor: Nilton OS - www.linuxpro.com.br
'#
'#
'### BEGIN INIT INFO
'# Provides: uwsgi
'# Required-Start: $ syslog $ remote_fs
'# Should-Start: $ time ypbind smtp
'# Required-Stop: $ syslog $ remote_fs
'# Should-Stop: ypbind smtp
'# Default-Start: 3 5
'# Default-Stop: 0 1 2 6
'### END INIT INFO code>
'# Source function library.
. /etc/rc.d/init.d/functions
'# Check for missing binaries (stale symlinks should not happen)
UWSGI_BIN = which uwsgi code>
test -x (UWSGI_BIN || {echo ") UWSGI_BIN not installed ";
if [" $ 1 "=" stop "]; then exit 0;
else exit 5; fi;}
UWSGI_EMPEROR_MODE = true
UWSGI_VASSALS = "/ etc / uwsgi /"
UWSGI_OPTIONS = "- enable-threads --logto /var/log/uwsgi/uwsgi.log"
lockfile = / var / lock / subsys / uwsgi
UWSGI_OPTIONS = "$ UWSGI_OPTIONS --autoload"
if [ "$ UWSGI_EMPEROR_MODE" = "true"]; then
UWSGI_OPTIONS = "$ UWSGI_OPTIONS --emperor $ UWSGI_VASSALS"
fi
case "$ 1" in
start)
echo -n "Starting uWSGI"
daemon $ UWSGI_BIN $ UWSGI_OPTIONS &
;;
stop)
echo -n "Shutting down uWSGI"
killproc $ UWSGI_BIN
;;
restart)
$ 0 stop
$ 0 start
;;
status)
echo -n "Checking for service uWSGI"
status $ UWSGI_BIN
;;
*)
echo " Usage: $ 0 {start | stop | status | restart} "
exit 1
;;
esac
exit 0
code>
According to the above command switch, you also need to add a uWSGI log file.
mkdir -p / var / log / uwsgi
touch /var/log/uwsgi/uwsgi.log
Code>
web2py installation
just need to install a so-called package web2py can unzip to the specified directory, you can download the binary package from the official website.
mkdir / var / www / html
unzip web2py_src.zip
mv web2py / handlers / wsgihandler.py web2py / wsgihandler.py
chown -R nginx: nginx web2py
cd web2py
sudo -u nginx python -c "from gluon.main import save_password; save_password ( 'password', 443)"
Code>
Configuration NginX
adding a server module, monitor port 80 will be accessed using uWSGI transferred to web2py.
server {
listen 80;
server_name YOUR_SERVER_FQDN;
'#to enable correct use of response.static_version
location ~* /(w+)/static(?:/_[d]+.[d]+.[d]+)?/(.*)$ {
alias /var/www/html/web2py/applications/$1/static/$2;
expires max;
}
location / {
uwsgi_pass 127.0.0.1:9090;
uwsgi_pass unix:///var/www/html/web2py/logs/web2py.socket;
include /etc/nginx/uwsgi_params;
}
}
}
code>
start Nginx and uWSGI
Note: web2py itself does not need to start with only passive call can be uWSGI.
/ Usr / local / nginx / sbin / nginx
/etc/init.d/uwsgi start
Code>
After more execution in the browser to access the server's IP address, if you need the following pages illustrate successful deployment.