1. Python HTTP Server
Python comes with a built-in HTTP server module.
Python 3:
bashpython3 -m http.server 8080
Python 2:
bashpython -m SimpleHTTPServer 8080
2. Apache HTTP Server
Apache is a widely used web server.
Start Apache:
bashsudo service apache2 start
3. Nginx
Nginx is another popular web server.
Start Nginx:
bashsudo service nginx start
4. PHP Built-in Server
PHP has a built-in server for development purposes.
Start PHP Server:
bashphp -S 0.0.0.0:8080
5. Ruby WEBrick
Ruby has a built-in web server called WEBrick.
Start WEBrick:
bashruby -run -e httpd . -p 8080
6. BusyBox HTTP Daemon
BusyBox includes a lightweight HTTP server.
Start BusyBox HTTP Daemon:
bashbusybox httpd -f -p 8080
7. Node.js HTTP Server
You can quickly set up a server using Node.js.
Install HTTP-Server:
bashnpm install -g http-server
Start HTTP-Server:
bashhttp-server -p 8080
8. SimpleHTTPServer in Perl
Perl can be used to start a simple HTTP server.
Start Perl HTTP Server:
bashperl -MIO::Socket::INET -e '$|=1; my $s = IO::Socket::INET->new(LocalPort => 8080, Listen => 10, Reuse => 1); while (my $c = $s->accept) { print $c "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nHello, World!\r\n"; close $c }'
9. SimpleHTTPServer in Bash
Using socat
in Bash to start an HTTP server.
Start Bash HTTP Server:
bashwhile true; do echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\nHello, World!" | socat TCP-LISTEN:8080,reuseaddr,fork -; done
10. Golang HTTP Server
If you have Go installed, you can use it to start a server.
Golang HTTP Server Code:
gopackage main
import (
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Run the Go Server:
bashgo run server.go
Each of these methods can be used to quickly spin up an HTTP server on Kali Linux for different purposes. Choose the one that best fits your needs.
Next Steps
Would you like to see more advanced configurations for any of these servers, such as enabling HTTPS or serving specific content types?
Comments
Post a Comment