Skip to content

Latest commit

Β 

History

History
156 lines (115 loc) Β· 2.94 KB

README.md

File metadata and controls

156 lines (115 loc) Β· 2.94 KB

ByteWebServer

It is designed to serve static websites and run PHP applications without requiring a full web server stack such as Apache or Nginx.

✨ Features

  • πŸš€ Lightweight Python HTTP server
  • 🌐 Static file hosting
  • 🐘 PHP CGI support
  • πŸ“„ Automatic index.html and index.php detection
  • πŸ”’ Basic path traversal protection
  • πŸ›‘οΈ Protected file path handling
  • ❌ Custom error pages
  • πŸ“¦ Automatic PHP setup
  • πŸ” MIME type detection
  • 🧡 Multi-threaded client handling
  • ⚑ Simple and easy to configure
  • πŸͺŸ Windows support

πŸ“ Project Structure

/
β”œβ”€β”€ server.py
β”œβ”€β”€ server.conf
β”œβ”€β”€ www/
β”‚   β”œβ”€β”€ index.html
β”‚   └── index.php
β”œβ”€β”€ errors/
β”‚   β”œβ”€β”€ 403.html
β”‚   β”œβ”€β”€ 404.html
β”‚   β”œβ”€β”€ 429.html
β”‚   └── 502.html
└── README.md

πŸš€ Getting Started

Requirements

  • Python 3.8+
  • Windows
  • PHP CGI (php-cgi.exe) for PHP support

Run the Server

python server.py

The server will start on:

http://localhost:80

If port 80 requires administrator privileges, change the port in server.py:

PORT = 8080

Then open:

http://localhost:8080

🐘 PHP Support

supports PHP through PHP CGI.

Configure the PHP CGI executable in:

PHP_CGI = r"C:\xampp\php\php-cgi.exe"

If PHP is not found, the server can automatically download and configure a PHP package.

🌐 Website Files

Place your website inside the www directory:

www/
β”œβ”€β”€ index.html
β”œβ”€β”€ style.css
β”œβ”€β”€ script.js
└── index.php

πŸ” Security

includes basic security protections such as:

  • Path traversal prevention
  • Unsafe path detection
  • Query string validation
  • CRLF request protection
  • Restricted document root
  • Safe PHP execution environment

is intended to be a lightweight development and personal hosting server. For production environments, a hardened web server such as Nginx or Apache is recommended.

πŸ“Š Server Response

Server: ByteWebServer/1.1
X-Powered-By: ByteWebServer

πŸ› οΈ Configuration

Basic configuration can be changed directly in server.py:

HOST = "0.0.0.0"
PORT = 80
WWW_DIR = "www"
PHP_CGI = r"C:\xampp\php\php-cgi.exe"

Configuration

Option Description
HOST Server bind address
PORT HTTP port
WWW_DIR Website root directory
PHP_CGI PHP CGI executable

πŸ“Œ Roadmap

  • HTTP/1.1 improvements
  • Keep-Alive support
  • Better request parsing
  • Access logs
  • Configuration file support
  • HTTPS support
  • Virtual hosts
  • Upload support
  • Better PHP CGI handling
  • Rate limiting
  • Admin dashboard

πŸ“œ License

This project is open-source. See the LICENSE file for details.



A simple Python web server for everyone.