description "uWSGI Emperor"
[uwsgi]
systemctl start emperor.uwsgi # stop,restart,status,...
[Unit]
#!/bin/bashecho 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh'echo 'Requires Ubuntu > 12.04 or Debian >= 8 and installs Nginx + uWSGI + Web2py'# Check if user has root privilegesif [[ $EUID -ne 0 ]]; then echo "You must run the script as root or using sudo" exit 1fi# parse command line argumentsnopassword=0nocertificate=0while [ "$#" -gt 0 ]; do case "$1" in --no-password) nopassword=1; shift 1;; --no-certificate) nocertificate=1; shift 1;; esacdone# Get Web2py Admin Passwordif [ "$nopassword" -eq 0 ]then echo -e "Web2py Admin Password: \c " read PWfi# Upgrade and install needed softwareapt-get updateapt-get -y upgradeapt-get autoremoveapt-get autocleanapt-get -y install nginx-fullapt-get -y install build-essential python-dev libxml2-dev python-pip unzippip install setuptools --no-use-wheel --upgradePIPPATH=`which pip`$PIPPATH install --upgrade uwsgi# Create common nginx sectionsmkdir /etc/nginx/conf.d/web2pyecho '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.confecho '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/web2pyecho 'server { listen 80; server_name $hostname; ###to enable correct use of response.static_version location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { alias /home/www-data/web2py/applications/$1/static/$2; 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; } ###
###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 / { #uwsgi_pass 127.0.0.1:9001; uwsgi_pass unix:///tmp/web2py.socket; include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; 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 { listen 443 default_server ssl; server_name $hostname; ssl_certificate /etc/nginx/ssl/web2py.crt; ssl_certificate_key /etc/nginx/ssl/web2py.key; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; keepalive_timeout 70; location / { #uwsgi_pass 127.0.0.1:9001; uwsgi_pass unix:///tmp/web2py.socket; include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; 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; ### } ###to enable correct use of response.static_version location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { alias /home/www-data/web2py/applications/$1/static/$2; 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; } ###
}' >/etc/nginx/sites-available/web2py
ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2pyrm /etc/nginx/sites-enabled/defaultmkdir /etc/nginx/sslcd /etc/nginx/sslif [ "$nocertificate" -eq 0 ]then openssl genrsa 1024 > web2py.key chmod 400 web2py.key openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt openssl x509 -noout -fingerprint -text < web2py.crt > web2py.infofi# Prepare folders for uwsgisudo mkdir /etc/uwsgisudo mkdir /var/log/uwsgisudo mkdir /etc/systemdsudo mkdir /etc/systemd/system
#uWSGI Emperorecho '[Unit]
Description = uWSGI EmperorAfter = syslog.target
[Service]ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.iniRuntimeDirectory = uwsgiRestart = alwaysKillSignal = SIGQUITType = notifyStandardError = syslogNotifyAccess = all
[Install]WantedBy = multi-user.target
' > /etc/systemd/system/emperor.uwsgi.service
# Create configuration file /etc/uwsgi/web2py.iniecho '[uwsgi]
socket = /tmp/web2py.socketpythonpath = /home/www-data/web2py/mount = /=wsgihandler:applicationprocesses = 4master = trueharakiri = 60reload-mercy = 8cpu-affinity = 1stats = /tmp/stats.socketmax-requests = 2000limit-as = 512reload-on-as = 256reload-on-rss = 192uid = www-datagid = www-datatouch-reload = /home/www-data/web2py/routes.pycron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -ono-orphans = true
' >/etc/uwsgi/web2py.ini
#Create a configuration file for uwsgi in emperor-mode#for Upstart in /etc/init/uwsgi-emperor.confecho '# Emperor uWSGI script
description "uWSGI Emperor"start on runlevel [2345]stop on runlevel [06]###remove the comments in the next section to enable static file compression for the welcome app#in that case, turn on gzip_static on; on /etc/nginx/nginx.conf###pre-start script# python /home/www-data/web2py/web2py.py -S welcome -R scripts/zip_static_files.py# chown -R www-data:www-data /home/www-data/web2py/*#end scriptrespawnexec uwsgi --master --die-on-term --emperor /etc/uwsgi --logto /var/log/uwsgi/uwsgi.log
' > /etc/init/uwsgi-emperor.conf# Install Web2pymkdir /home/www-datacd /home/www-dataunzip web2py_src.zipmv web2py/handlers/wsgihandler.py web2py/wsgihandler.pyrm web2py_src.zipchown -R www-data:www-data web2pycd /home/www-data/web2pyif [ "$nopassword" -eq 0 ]then sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)"fi
sudo systemctl restart nginxsudo systemctl restart emperor.uwsgi
echo <<EOFyou can stop uwsgi and nginx with
sudo systemctl stop nginx sudo systemctl stop emperor.uwsgi and start it with
sudo systemctl start nginx sudo systemctl start emperor.uwsgi
EOF
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
--
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
thz i have been solved.
Now other error is i cannot import some module althougn i have been installed and tested on python. But in web2py controller i can't import module
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.