1.7 KiB
1.7 KiB
HTTP Server
This is a simple HTTP server for linux operating system written in C. It supports basic HTTP requests, logging, etc.
Features
- Handles GET requests for static files.
- Supports a control menu for managing server status, logging, and configuration (currently basic).
- Uses pthreads for concurrent client handling.
- Includes basic logging functionality with timestamps.
- Configuration is loaded from a JSON file (
server.json).
Build Instructions
-
Prerequisites:
- GCC compiler
- Make (recommended)
- OpenSSL libraries (
libssl,libcrypto) - pthreads library
- cJSON library
-
Clone the repository (optional):
git clone https://github.com/Azreyo/Http-server cd Http-server -
Compile:
gcc server.c config_parser.c server_config.c -o server -lssl -lcrypto -lpthread -pthread -lcjson -lcjson -I/usr/include/cjsonCompile it in raw gcc
makeThis command will use the provided
Makefileto compile the source files, link the necessary libraries, and create the executable in thebindirectory. -
Create
wwwdirectory:mkdir wwwPlace your HTML files (e.g.,
index.html) inside thewwwdirectory. -
Create
server.json:Create a
server.jsonfile in the same directory as the executable with the following structure:{ "port": 8080, "use_https": false, "log_file": "server.log", "max_threads": 4, "running": true }Adjust the values as needed.
use_httpsis not yet implemented.
Run Instructions
./bin/server # Run the executable from the bin directory