follow the usual steps to install python 2.7.3 and django 1.4.2 , then setup a project and app:
django-admin.py startproject helloworld
chmod +x helloworld/manage.py
helloworld/manage.py startapp hello
vi helloworld/settings.py
...
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs',
'hello',
)
note this handles two different URL patterns: 192.168.1.2/ and 192.168.1.2/hello
when the regex matches "begins with hello" then it returns the function hello from the view in the hello application
from django.conf.urls import patterns, include, url
urlpatterns = patterns('', (r'^$','hello.views.hello'), (r'^hello','hello.views.hello'), )
vi helloworld/hello/views.py
from django.http import HttpResponse
def hello(request): return HttpResponse("Hello world")
You can verify the python django app is running using the dev web engine ./manage.py runserver 0.0.0.0:8888
sudo apt-get update sudo apt-get install python-software-properties sudo add-apt-repository ppa:cherokee-webserver/ppa sudo apt-get update sudo apt-get install cherokee cherokee-admin sudo apt-get install python-flup # Easiest but may not be the most performant
sudo cherokee-admin # by default only allows the local machine to access 127.0.0.1:9090 sudo cherokee-admin -b # binds to all ports so a remote computer can access, still uses the one time use password
get around non root user service under port 1024, better may be iptables redirect
Cherokee -> General -> Ports to listen -> Add new port 8080 -> remove port 80
redirect: /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables-save (or use a bash script on boot)
the DJANGO application will only be available on the port that's bound
somehow the config above managed to bind to port 80 anyways
/var/www contains a symlink to cherokee's default index.html which can be replaced
vServers -> + (new server) -> Platforms -> Django (Add) => Django Local Directory = directory of the Project, e.g. helloworld
Cherokee Home -> Start Server
http://example.com:8080
OR CHANGE Virtual Server -> Host Match -> Method -> Server IP -> IP or Subnet = 10.10.10.202/255.255.255.255
http://10.10.10.202:8080/
If you dig in Cherokee's settings you'll find SCGI is handling Django's dynamic content Sources -> Django 1 -> /usr/bin/python /home/ubuntu/DJANGO/helloworld/manage.py runfcgi protocol=scgi host=127.0.0.1 port=38191
http://www.cherokee-project.com/doc/cookbook_drupal.html
(assuming you've already installed cherokee with php) apt-get install mysql apt-get install php-mysql5 php5-gd
cherokee-admin Create a new Virtual Server (i.e. physicstime.com ) Delete all rules except the Default Modify Default: Handler = Redirection: External regex (.*)$ substitution http://newsite.com/$1 Add a PHP rule Extensions php Behavior rule should have "Check local file" un
VirtualServer - Error Handler: Custom redirections = Error 404 , Redirect /index.php Type Internal
extract the source-drupal-folder.tar.gz into somewhere like /var/www (ensure that any chown user:www-data /var/www/newsite.com -R is completed!)
chmod 600 sites/default/settings.php modify the sites/default/settings.php chmod 440 sites/default/settings.php
( might be necessary to: service stop cherokee, kill php5-cgi aka pkill -u www-data , service stop mysql ) ( service start cherokee, service start mysql ) http://newsite.com/index.php
cherokee evaluates Virtual Server from top to bottom - the last one is the "default"
linode-ubuntu-10-04-64bit
easy setup = $20 / month = 512MB RAM 8192 GB Hard drive
root into static ip address
MAINTENANCE
apt-get update apt-get upgrade
ps aux | sort -k 4 -r | head
SECURITY
useradd USERNAME
nano /etc/ssh/sshd_config
Port 12345 PermitRootLogin no
AllowUsers USERNAME
nano /etc/hostname nano /etc/hosts
SSH TUNNEL TO ALLOW CHEROKEE ADMINISTRATION
putty portable => Connection -> SSH -> Tunnels 9090 localhost:9090 (click ADD)
ssh -L 9090:localhost:9090 user@hostname -p 12345 (creating the 9090 tunnel for secure access to cherokee admin)
OPTIONAL BLEEDING EDGE
echo deb http://ppa.launchpad.net/cherokee-webserver/ppa/ubuntu lucid main >> /etc/apt/sources.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBA7BD49
(the signed key at the end came from https://launchpad.net/~cherokee-webserver/+archive/ppa )
apt-get install cherokee apt-get install php5-cgi
netstat -an (shows listening on port 80) http://ipaddress
sudo cherokee-admin
Login: User: admin One-time Password: kRuEIvSqko4ZVca3
Web Interface: URL: http://127.0.0.1:9090/
USING THE SSH TUNNEL ABOVE ...
http://localhost:9090
Go to vServers -> click on default (now it will display Virtual Server: default) Click on the BEHAVIOR tab -> Rule Management (Button) Now the top left should show Behavior (with only Default listed) Click on the + -> Languages -> PHP -> Add -> Create Click on the NON FINAL (in the left column next to Extensions PHP) - becomes FINAL Click on the SAVE (button in the top right corner) Then stop and restart Cherokee (Home? Hard restart) Now the Behavior tab will have
Behavior Rules Match Handler Auth Root Secure Enc Cache Exp Timeout Shaping Log Final Extensions php FastCGI Enabled Enabled Enabled Enabled Enabled Default Forbidden Enabled Enabled
vi /var/www/test.php <?php phpinfo(); ?> http://ipaddressordomain/test.php