From ba6ba5342a91ac375296df99dd082d8a258eda1f Mon Sep 17 00:00:00 2001 From: Massimo DiPierro Date: Mon, 21 May 2012 16:50:03 -0500 Subject: [PATCH] better setup-web2py-nginx-uwsgi-ubuntu.sh, issue 816, thanks Orsomannaro --- VERSION | 2 +- scripts/setup-web2py-nginx-uwsgi-ubuntu.sh | 160 ++++++++++----------- 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/VERSION b/VERSION index 2d4db54a..ec33540d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-05-21 10:08:41) dev +Version 2.00.0 (2012-05-21 16:49:59) dev diff --git a/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh b/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh index 67a20db8..1d50f6ad 100644 --- a/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh +++ b/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh @@ -1,81 +1,79 @@ -#!/bin/bash - -echo 'setup-web2py-nginx-uwsgi-ubuntu.sh' -echo 'Requires Ubuntu 10.04 (LTS) and installs Nginx + uWSGI + Web2py' - -# Get Web2py Admin Password -echo -e "Web2py Admin Password: \c " -read PW - -# Upgrade and install needed software -apt-get update -apt-get -y upgrade -apt-get install python-software-properties -add-apt-repository ppa:nginx/stable -add-apt-repository ppa:uwsgi/release -apt-get update -apt-get -y install nginx-full -apt-get -y install uwsgi-python - -# Create configuration file /etc/nginx/sites-available/web2py -echo 'server { - listen 80; - server_name $hostname; - location ~* /(\w+)/static/ { - root /home/www-data/web2py/applications/; - } - location / { - uwsgi_pass 127.0.0.1:9001; - include uwsgi_params; - uwsgi_param UWSGI_SCHEME $scheme; - uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; - } -} - -server { - listen 443; - server_name $hostname; - ssl on; - ssl_certificate /etc/nginx/ssl/web2py.crt; - ssl_certificate_key /etc/nginx/ssl/web2py.key; - location / { - uwsgi_pass 127.0.0.1:9001; - include uwsgi_params; - uwsgi_param UWSGI_SCHEME $scheme; - uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; - } - -}' >/etc/nginx/sites-available/web2py - -ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py -rm /etc/nginx/sites-enabled/default -rm /etc/nginx/sites-available/default -mkdir /etc/nginx/ssl -cd /etc/nginx/ssl -openssl genrsa -out web2py.key 1024 -openssl req -batch -new -key web2py.key -out web2py.csr -openssl x509 -req -days 1780 -in web2py.csr -signkey web2py.key -out web2py.crt - -# Create configuration file /etc/uwsgi-python/apps-available/web2py.xml -echo ' - 127.0.0.1:9001 - /home/www-data/web2py/ - - - -' >/etc/uwsgi-python/apps-available/web2py.xml -ln -s /etc/uwsgi-python/apps-available/web2py.xml /etc/uwsgi-python/apps-enabled/web2py.xml - -# Install Web2py -apt-get -y install unzip -cd /home -mkdir www-data -cd www-data -wget http://web2py.com/examples/static/web2py_src.zip -unzip web2py_src.zip -rm web2py_src.zip -chown -R www-data:www-data web2py -cd /home/www-data/web2py -sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" -/etc/init.d/uwsgi-python restart -/etc/init.d/nginx restart +#!/bin/bash + +echo 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh' +echo 'Requires Ubuntu 12.04 and installs Nginx + uWSGI + Web2py' + +# Get Web2py Admin Password +echo -e "Web2py Admin Password: \c " +read PW + +# Upgrade and install needed software +apt-get update +apt-get -y upgrade +apt-get -y dist-upgrade +apt-get autoremove +apt-get autoclean +apt-get -y install nginx-full +apt-get -y install uwsgi uwsgi-plugin-python + +# Create configuration file /etc/nginx/sites-available/web2py +echo 'server { + listen 80; + server_name $hostname; + location ~* /(\w+)/static/ { + root /home/www-data/web2py/applications/; + } + location / { + uwsgi_pass 127.0.0.1:9001; + include uwsgi_params; + uwsgi_param UWSGI_SCHEME $scheme; + uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; + } +} + +server { + listen 443; + server_name $hostname; + ssl on; + ssl_certificate /etc/nginx/ssl/web2py.crt; + ssl_certificate_key /etc/nginx/ssl/web2py.key; + location / { + uwsgi_pass 127.0.0.1:9001; + include uwsgi_params; + uwsgi_param UWSGI_SCHEME $scheme; + uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; + } + +}' >/etc/nginx/sites-available/web2py + +ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py +rm /etc/nginx/sites-enabled/default +mkdir /etc/nginx/ssl +cd /etc/nginx/ssl +openssl genrsa -out web2py.key 1024 +openssl req -batch -new -key web2py.key -out web2py.csr +openssl x509 -req -days 1780 -in web2py.csr -signkey web2py.key -out web2py.crt + +# Create configuration file /etc/uwsgi/apps-available/web2py.xml +echo ' + python + 127.0.0.1:9001 + /home/www-data/web2py/ + + + +' >/etc/uwsgi/apps-available/web2py.xml +ln -s /etc/uwsgi/apps-available/web2py.xml /etc/uwsgi/apps-enabled/web2py.xml + +# Install Web2py +apt-get -y install unzip +mkdir /home/www-data +cd /home/www-data +wget http://web2py.com/examples/static/web2py_src.zip +unzip web2py_src.zip +rm web2py_src.zip +chown -R www-data:www-data web2py +cd /home/www-data/web2py +sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" +/etc/init.d/uwsgi restart +/etc/init.d/nginx restart