source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/scripts/setup-web2py-ubuntu.sh @ 42095c5

mainqndtest v1.1.1
Last change on this file since 42095c5 was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 4.6 KB
Line 
1#!/bin/bash
2echo "This script will:
31) install all modules need to run web2py on Ubuntu 14.04
42) install web2py in /home/www-data/
53) create a self signed ssl certificate
64) setup web2py with mod_wsgi
75) overwrite /etc/apache2/sites-available/default
86) restart apache.
9
10You may want to read this script before running it.
11
12Press a key to continue...[ctrl+C to abort]"
13
14read CONFIRM
15
16
17# optional
18# dpkg-reconfigure console-setup
19# dpkg-reconfigure timezoneconf
20# nano /etc/hostname
21# nano /etc/network/interfaces
22# nano /etc/resolv.conf
23# reboot now
24# ifconfig eth0
25
26echo "installing useful packages"
27echo "=========================="
28apt-get update
29apt-get -y install ssh
30apt-get -y install zip unzip
31apt-get -y install tar
32apt-get -y install openssh-server
33apt-get -y install build-essential
34apt-get -y install python3
35apt-get -y install ipython3
36apt-get -y install python3-dev
37apt-get -y install postgresql
38apt-get -y install apache2
39apt-get -y install libapache2-mod-wsgi
40apt-get -y install python3-psycopg2
41apt-get -y install postfix
42apt-get -y install wget
43apt-get -y install python3-matplotlib
44apt-get -y install python3-reportlab
45apt-get -y install mercurial
46/etc/init.d/postgresql restart
47
48# optional, uncomment for emacs
49# apt-get -y install emacs
50
51# optional, uncomment for backups using samba
52# apt-get -y install samba
53# apt-get -y install smbfs
54
55echo "downloading, installing and starting web2py"
56echo "==========================================="
57cd /home
58mkdir www-data
59cd www-data
60rm web2py_src.zip*
61wget http://web2py.com/examples/static/web2py_src.zip
62unzip web2py_src.zip
63mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py
64chown -R www-data:www-data web2py
65
66echo "setting up apache modules"
67echo "========================="
68a2enmod ssl
69a2enmod proxy
70a2enmod proxy_http
71a2enmod headers
72a2enmod expires
73a2enmod wsgi
74a2enmod rewrite  # for 14.04
75mkdir /etc/apache2/ssl
76
77echo "creating a self signed certificate"
78echo "=================================="
79openssl genrsa 1024 > /etc/apache2/ssl/self_signed.key
80chmod 400 /etc/apache2/ssl/self_signed.key
81openssl req -new -x509 -nodes -sha1 -days 365 -key /etc/apache2/ssl/self_signed.key > /etc/apache2/ssl/self_signed.cert
82openssl x509 -noout -fingerprint -text < /etc/apache2/ssl/self_signed.cert > /etc/apache2/ssl/self_signed.info
83
84echo "rewriting your apache config file to use mod_wsgi"
85echo "================================================="
86echo '
87WSGIDaemonProcess web2py user=www-data group=www-data
88
89<VirtualHost *:80>
90
91 WSGIProcessGroup web2py
92  WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
93  WSGIPassAuthorization On
94
95  <Directory /home/www-data/web2py>
96    AllowOverride None
97    Require all denied
98    <Files wsgihandler.py>
99      Require all granted
100    </Files>
101  </Directory>
102
103  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
104        /home/www-data/web2py/applications/$1/static/$2
105
106  <Directory /home/www-data/web2py/applications/*/static/>
107    Options -Indexes
108    ExpiresActive On
109    ExpiresDefault "access plus 1 hour"
110    Require all granted
111  </Directory>
112
113  CustomLog /var/log/apache2/access.log common
114  ErrorLog /var/log/apache2/error.log
115</VirtualHost>
116
117<VirtualHost *:443>
118  SSLEngine on
119  SSLCertificateFile /etc/apache2/ssl/self_signed.cert
120  SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
121
122  WSGIProcessGroup web2py
123  WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
124  WSGIPassAuthorization On
125
126  <Directory /home/www-data/web2py>
127    AllowOverride None
128    Require all denied
129    <Files wsgihandler.py>
130      Require all granted
131    </Files>
132  </Directory>
133
134  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
135        /home/www-data/web2py/applications/$1/static/$2
136
137  <Directory /home/www-data/web2py/applications/*/static/>
138    Options -Indexes
139    ExpiresActive On
140    ExpiresDefault "access plus 1 hour"
141    Require all granted
142  </Directory>
143
144  CustomLog /var/log/apache2/ssl-access.log common
145  ErrorLog /var/log/apache2/error.log
146</VirtualHost>
147' > /etc/apache2/sites-available/default.conf  # FOR 14.04
148
149sudo rm /etc/apache2/sites-enabled/*    # FOR 14.04
150sudo a2ensite default                   # FOR 14.04
151
152# echo "setting up PAM"
153# echo "================"
154# sudo apt-get install pwauth
155# sudo ln -s /etc/apache2/mods-available/authnz_external.load /etc/apache2/mods-enabled
156# ln -s /etc/pam.d/apache2 /etc/pam.d/httpd
157# usermod -a -G shadow www-data
158
159echo "restarting apache"
160echo "================"
161
162/etc/init.d/apache2 restart
163cd /home/www-data/web2py
164sudo -u www-data python -c "from gluon.widget import console; console();"
165sudo -u www-data python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),443)"
166echo "done!"
Note: See TracBrowser for help on using the repository browser.