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:
- Servers > + > Platforms > uWSGI > Add > Next
- Configuration File: /var/web2py/config.xml
- Next
- New Host Name: SERVER.IP.ADDRESS
- Document Root: /var/web2py
- Use Same Logs as: default (combined)
- Create
- Save
- Hard Restart
Then go to SERVER.IP.ADDRESS in your browser and you should see the Web2py intro page.
To finish the SSL setup:
- In General, "Add new port..." > Port: 443 > Add
- Check "TLS/SSL port"
- In vServers > Default, set Certificate and Certificate Key to '/etc/cherokee/ssl/server.pem'
- Then if you have any other vServers, set Certificate and Certificate Key to '/etc/cherokee/ssl/server.pem'
- Save > Hard Restart
Many thanks to Gray Matter for the original slice: http://web2pyslices.com/main/slices/take_slice/64
Comments (1)
1
muybay 13 years ago