Skip to content

magentix/msphs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSPHS

A minimal secure HTTP Server in PHP.

About

This software is only able to display a static site. It can be used for educational purposes:

  • Work with Socket in PHP
  • Establish a secure connection with TLS 1.3
  • Learn more about HTTP status and headers

Requirements

  • PHP >= 8.0
  • OpenSSL >= 1.1.1

Files

  • www: the static website directory
  • server.php: the script to run
  • cert.pem: the certificate full chain (generated)
  • key.pem: the certificate private key (generated)

Generate the certificate

Local

Self-signed certificate:

openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

Live

Let's Encrypt certificate:

apt-get install certbot
certbot certonly --standalone -d example.com --staple-ocsp -m hello@example.com --agree-tos
ln -s /etc/letsencrypt/live/example.com/fullchain.pem cert.pem
ln -s /etc/letsencrypt/live/example.com/privkey.pem key.pem

Start the server

php server.php &

Notes

On any secure connection, the TLS handshake takes between 10 and 20ms.

About

Minimal Secure PHP HTTP Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors