Created
January 16, 2017 18:17
-
-
Save Mexarm/e7b5e9e8a8fdf5f6bf33a618d69605ca to your computer and use it in GitHub Desktop.
install all modules need to run web2py on Rapsberry Pi Jessie Minimal and other tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "This script will: | |
| 1) install all modules need to run web2py on Jessie Minimal and other tools | |
| 2) install web2py in /home/www-data/ | |
| 3) create a self signed ssl certificate | |
| 4) setup web2py with mod_wsgi | |
| 5) overwrite /etc/apache2/sites-available/default | |
| 6) restart apache. | |
| Press a key to continue...[ctrl+C to abort]" | |
| read CONFIRM | |
| echo "installing useful packages" | |
| echo "==========================" | |
| apt-get update | |
| apt-get -y install ssh | |
| apt-get -y install build-essential | |
| apt-get -y install python-dev | |
| apt-get -y install python-pip | |
| apt-get -y install apache2 | |
| apt-get -y install libapache2-mod-wsgi | |
| echo "downloading, installing and starting web2py" | |
| echo "===========================================" | |
| cd /home | |
| mkdir www-data | |
| cd www-data | |
| rm web2py_src.zip* | |
| wget http://web2py.com/examples/static/web2py_src.zip | |
| unzip web2py_src.zip | |
| mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py | |
| chown -R www-data:www-data web2py | |
| echo "setting up apache modules" | |
| echo "=========================" | |
| a2enmod ssl | |
| a2enmod proxy | |
| a2enmod proxy_http | |
| a2enmod headers | |
| a2enmod expires | |
| a2enmod wsgi | |
| a2enmod rewrite | |
| mkdir /etc/apache2/ssl | |
| echo "creating a self signed certificate" | |
| echo "==================================" | |
| openssl genrsa 1024 > /etc/apache2/ssl/self_signed.key | |
| chmod 400 /etc/apache2/ssl/self_signed.key | |
| openssl req -new -x509 -nodes -sha1 -days 365 -key /etc/apache2/ssl/self_signed.key > /etc/apache2/ssl/self_signed.cert | |
| openssl x509 -noout -fingerprint -text < /etc/apache2/ssl/self_signed.cert > /etc/apache2/ssl/self_signed.info | |
| echo "rewriting your apache config file to use mod_wsgi" | |
| echo "=================================================" | |
| echo ' | |
| WSGIDaemonProcess web2py user=www-data group=www-data | |
| <VirtualHost *:80> | |
| WSGIProcessGroup web2py | |
| WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py | |
| WSGIPassAuthorization On | |
| <Directory /home/www-data/web2py> | |
| AllowOverride None | |
| Require all denied | |
| <Files wsgihandler.py> | |
| Require all granted | |
| </Files> | |
| </Directory> | |
| AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \ | |
| /home/www-data/web2py/applications/$1/static/$2 | |
| <Directory /home/www-data/web2py/applications/*/static/> | |
| Options -Indexes | |
| ExpiresActive On | |
| ExpiresDefault "access plus 1 hour" | |
| Require all granted | |
| </Directory> | |
| CustomLog /var/log/apache2/access.log common | |
| ErrorLog /var/log/apache2/error.log | |
| </VirtualHost> | |
| <VirtualHost *:443> | |
| SSLEngine on | |
| SSLCertificateFile /etc/apache2/ssl/self_signed.cert | |
| SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key | |
| WSGIProcessGroup web2py | |
| WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py | |
| WSGIPassAuthorization On | |
| <Directory /home/www-data/web2py> | |
| AllowOverride None | |
| Require all denied | |
| <Files wsgihandler.py> | |
| Require all granted | |
| </Files> | |
| </Directory> | |
| AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \ | |
| /home/www-data/web2py/applications/$1/static/$2 | |
| <Directory /home/www-data/web2py/applications/*/static/> | |
| Options -Indexes | |
| ExpiresActive On | |
| ExpiresDefault "access plus 1 hour" | |
| Require all granted | |
| </Directory> | |
| CustomLog /var/log/apache2/ssl-access.log common | |
| ErrorLog /var/log/apache2/error.log | |
| </VirtualHost> | |
| ' > /etc/apache2/sites-available/default.conf # FOR 14.04 | |
| sudo rm /etc/apache2/sites-enabled/* # FOR 14.04 | |
| sudo a2ensite default # FOR 14.04 | |
| echo "restarting apache" | |
| echo "================" | |
| /etc/init.d/apache2 restart | |
| cd /home/www-data/web2py | |
| sudo -u www-data python -c "from gluon.widget import console; console();" | |
| sudo -u www-data python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),443)" | |
| echo "done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment