1) install Lighttpd:
Wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.30.tar.gz
./Configure-Prefix/opt/modules/Lighttpd
Make
Make install
Cp doc/initscripts/rc. Lighttpd. RedHat/etc/init. d/Lighttpd
Modify the Startup Script: to modify row 29th:
Lighttpd = "/opt/modules/Lighttpd/sbin/Lighttpd"
Chmod A + Rx/etc/init. d/Lighttpd
CP-r DOC/config/CONF. d/etc/Lighttpd/
CP-r DOC/config/vhosts. d // etc/Lighttpd/
Cp doc/config/*. CONF/etc/Lighttpd/
Modify the Lighttpd configuration file: VI/etc/Lighttpd. conf
Var. basedir = "/var/www/localhost"
Var. logdir = "/var/log /"
# Load modules to be used
Server. Modules = (
"Mod_access ",
"Mod_fastcgi ",
"Mod_rewrite ",
"Mod_accesslog ",
)
Server.doc ument-root = "/opt/test"
Server. PID-file = "/opt/test/Lighttpd. PID"
Server. errorlog = var. logdir + "/lighttpd-error.log"
Server. Port = 9001
Accesslog. filename = var. logdir + "/lighttpd-access.log"
# FastCGI Module Settings
FastCGI. Server = ("/test. py" =>
((
"Socket" => "/tmp/fastcgi-wen.socket ",
"Bin-path" => "/opt/test/testpy ",
"Max-procs" => 2, # Number of Python sub-Processes
"Check-local" => "Disable ",)))
# Rewrite Module Settings
URL. Rewrite-once = (
"^/(. *) $" => "/Test. py/$1", # redirect all requests to hello. py
)
2) Install Web. py
Easy_install web. py
If easy_install installation fails, you can also download the source code package for installation:
Python setup. py install
3) Hello world test:
#! /Usr/bin/ENV Python
Import Web
URLs = (
'/(. *)', 'Hello'
)
APP = web. Application (URLs, globals ())
Class Hello:
Def get (self, name ):
If not name:
Name = 'World'
Return 'hello, '+ name + '! '
If _ name _ = "_ main __":
App. Run ()
Run: Python test. py
Output: http: // 0.0.0.0: 8080/
Open another window to access: curl http: // 0.0.0.0: 8080/
If the request is successful, the system returns: Hello world.
Modify the script permission to 755
4) Start Lighttpd:/etc/init. d/Lighttpd restart
Check the error log to ensure the startup is successful.
5) curl http: // 0.0.0.0: 9001/