more modular setup-web2py-nginx-uwsgi-ubuntu, thanks Paolo and Niphlod

This commit is contained in:
Massimo
2013-01-24 15:52:21 -06:00
parent 356643d509
commit d4e68e6c18
2 changed files with 70 additions and 22 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.01.24.10.51.01 Version 2.4.1-alpha.2+timestamp.2013.01.24.15.51.43
+69 -21
View File
@@ -19,19 +19,50 @@ apt-get -y install build-essential python-dev libxml2-dev python-pip unzip
pip install --upgrade pip pip install --upgrade pip
PIPPATH=`which pip` PIPPATH=`which pip`
$PIPPATH install --upgrade uwsgi $PIPPATH install --upgrade uwsgi
# Create common nginx sections
mkdir /etc/nginx/conf.d/web2py
echo '
gzip_static on;
gzip_http_version 1.1;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
' > /etc/nginx/conf.d/web2py/gzip_static.conf
echo '
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
' > /etc/nginx/conf.d/web2py/gzip.conf
# Create configuration file /etc/nginx/sites-available/web2py # Create configuration file /etc/nginx/sites-available/web2py
echo 'server { echo 'server {
listen 80; listen 80;
server_name $hostname; server_name $hostname;
#to enable correct use of response.static_version ###to enable correct use of response.static_version
#location ~* /(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { #location ~* /(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
# alias /home/www-data/web2py/applications/$1/static/$2; # alias /home/www-data/web2py/applications/$1/static/$2;
# expires max; # expires max;
#} #}
###
###if you use something like myapp = dict(languages=['en', 'it', 'jp'], default_language='en') in your routes.py
#location ~* /(\w+)/(en|it|jp)/static/(.*)$ {
# alias /home/www-data/web2py/applications/$1/;
# try_files static/$2/$3 static/$3 =404;
#}
###
location ~* /(\w+)/static/ { location ~* /(\w+)/static/ {
root /home/www-data/web2py/applications/; root /home/www-data/web2py/applications/;
#remove next comment on production #remove next comment on production
#expires max; #expires max;
### if you want to use pre-gzipped static files (recommended)
### check scripts/zip_static_files.py and remove the comments
# include /etc/nginx/conf.d/web2py/gzip_static.conf;
###
} }
location / { location / {
#uwsgi_pass 127.0.0.1:9001; #uwsgi_pass 127.0.0.1:9001;
@@ -39,6 +70,14 @@ echo 'server {
include uwsgi_params; include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
###remove the comments to turn on if you want gzip compression of your pages
# include /etc/nginx/conf.d/web2py/gzip.conf;
### end gzip section
### remove the comments if you use uploads (max 10 MB)
#client_max_body_size 10m;
###
} }
} }
server { server {
@@ -58,7 +97,15 @@ server {
include uwsgi_params; include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
###remove the comments to turn on if you want gzip compression of your pages
# include /etc/nginx/conf.d/web2py/gzip.conf;
### end gzip section
### remove the comments if you want to enable uploads (max 10 MB)
#client_max_body_size 10m;
###
} }
## if you serve static files through https, copy here the section
## from the previous server instance to manage static files
}' >/etc/nginx/sites-available/web2py }' >/etc/nginx/sites-available/web2py
@@ -78,25 +125,26 @@ sudo mkdir /etc/uwsgi
sudo mkdir /var/log/uwsgi sudo mkdir /var/log/uwsgi
# Create configuration file /etc/uwsgi/web2py.xml # Create configuration file /etc/uwsgi/web2py.xml
echo '<uwsgi> echo '[uwsgi]
<socket>/tmp/web2py.socket</socket>
<pythonpath>/home/www-data/web2py/</pythonpath> socket = /tmp/web2py.socket
<mount>/=wsgihandler:application</mount> pythonpath = /home/www-data/web2py/
<master/> mount = /=wsgihandler:application
<processes>4</processes> processes = 4
<harakiri>60</harakiri> master = true
<reload-mercy>8</reload-mercy> harakiri = 60
<cpu-affinity>1</cpu-affinity> reload-mercy = 8
<stats>/tmp/stats.socket</stats> cpu-affinity = 1
<max-requests>2000</max-requests> stats = /tmp/stats.socket
<limit-as>512</limit-as> max-requests = 2000
<reload-on-as>256</reload-on-as> limit-as = 512
<reload-on-rss>192</reload-on-rss> reload-on-as = 256
<uid>www-data</uid> reload-on-rss = 192
<gid>www-data</gid> uid = www-data
<cron>0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o</cron> gid = www-data
<no-orphans/> cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
</uwsgi>' >/etc/uwsgi/web2py.xml no-orphans = true
' >/etc/uwsgi/web2py.ini
#Create a configuration file for uwsgi in emperor-mode #Create a configuration file for uwsgi in emperor-mode
#for Upstart in /etc/init/uwsgi-emperor.conf #for Upstart in /etc/init/uwsgi-emperor.conf
@@ -135,4 +183,4 @@ start uwsgi-emperor
## and stop it with ## and stop it with
# stop uwsgi-emperor # stop uwsgi-emperor
## to reload web2py only (without restarting uwsgi) ## to reload web2py only (without restarting uwsgi)
# touch /etc/uwsgi/web2py.xml # touch /etc/uwsgi/web2py.xml