A minimal secure HTTP Server in PHP.
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
- PHP >= 8.0
- OpenSSL >= 1.1.1
- 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)
Self-signed certificate:
openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
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
php server.php &
On any secure connection, the TLS handshake takes between 10 and 20ms.