If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

After creating a new Ubuntu 10.04 image (Amazon AWS, RackSpace Cloud, etc), ssh in to te server and:

sudo vi setup.sh
i
[paste the script]
esc
:wq
sudo chmod +x setup.sh
sudo ./setup.sh

The script:

#!/bin/bash

/usr/sbin/locale-gen en_US.UTF-8
/usr/sbin/update-locale LANG=en_US.UTF-8

apt-get update
apt-get -y upgrade

apt-get -y install wget zip unzip tar
apt-get -y install build-essential
apt-get -y install python-dev
apt-get -y install python-software-properties
apt-get -y install libxml2-dev

# install web2py
cd /var
rm web2py_src.zip*
wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
chown -R www-data:www-data /var/web2py

# install uwsgi
cd /var
wget http://projects.unbit.it/downloads/uwsgi-0.9.6.5.tar.gz
tar -zxvf uwsgi-0.9.6.5.tar.gz
cd uwsgi-0.9.6.5
python uwsgiconfig.py --build
cp uwsgi /usr/local/bin/uwsgi
echo '
<uwsgi>
    <pythonpath>/var/web2py/</pythonpath>
    <app mountpoint="/">
    <script>wsgihandler</script>
    </app>
</uwsgi>
' > /var/web2py/config.xml

#install cherokee
add-apt-repository ppa:cherokee-webserver
apt-get update
apt-get -y install cherokee
apt-get -y install rrdtool
apt-get -y install libcherokee-mod-rrd
apt-get -y install libcherokee-mod-libssl

# self-signed certs
mkdir /etc/cherokee/ssl
cd /etc/cherokee/ssl
dd if=/dev/random of=rand.dat bs=1024 count=1
openssl genrsa -out cakey.key -rand rand.dat 2048
openssl req -new -key cakey.key -out cakey.csr
openssl x509 -req -days 1780 -set_serial 1 -in cakey.csr -signkey cakey.key -out cakey.pem
cat cakey.key cakey.pem > server.pem
rm -f rand.dat

# set password for web2py
cd /var/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)"

To complete the Cherokee installation, you need to use the Cherokee Admin front-end.

cherokee-admin

Cherokee Admin can only be access from "localhost" so open up a new terminal window and:

ssh -L 9090:localhost:9090 root@SERVER.IP.ADDRESS

In a browser, go to "http://localhost:9090" and enter "admin" and the password generated by cherokee-admin.

Then follow these steps to set up your vServer:

  1. Servers > + > Platforms > uWSGI > Add > Next
  2. Configuration File: /var/web2py/config.xml
  3. Next
  4. New Host Name: SERVER.IP.ADDRESS
  5. Document Root: /var/web2py
  6. Use Same Logs as: default (combined)
  7. Create
  8. Save
  9. Hard Restart

Then go to SERVER.IP.ADDRESS in your browser and you should see the Web2py intro page.

To finish the SSL setup:

  1. In General, "Add new port..." > Port: 443 > Add
  2. Check "TLS/SSL port"
  3. In vServers > Default, set Certificate and Certificate Key to '/etc/cherokee/ssl/server.pem'
  4. Then if you have any other vServers, set Certificate and Certificate Key to '/etc/cherokee/ssl/server.pem'
  5. Save > Hard Restart

Many thanks to Gray Matter for the original slice: http://web2pyslices.com/main/slices/take_slice/64

Related slices

Comments (1)


Hosting graciously provided by:
Python Anywhere