This repository provides a guide for setting up an Apache server with PHP support inside a Docker container, secured with an SSL certificate for local development purposes.
- Docker installed on your machine.
- Basic knowledge of Docker, Apache, and SSL certificates.
- OpenSSL for generating a self-signed certificate.
To use this setup, follow these steps:
git clone https://github.com/tshenolo/docker-Secure-Apache.git
cd docker-Secure-Apache
Before setting up your Docker container, you need to generate a self-signed SSL certificate for localhost. Open a terminal and run the following command:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -subj "/C=US/ST=YourState/L=YourCity/O=YourOrganization/CN=localhost"
This command generates a new SSL certificate (localhost.crt) and a private key (localhost.key), valid for 365 days.
docker build -t apache-php-ssl .
docker run -d -p 443:443 apache-php-ssl
Open a web browser and navigate to https://localhost. You should see your PHP application running securely under HTTPS. Since the certificate is self-signed, your browser may warn you about the site's security certificate. You can proceed by allowing an exception for this certificate.
You've successfully set up an Apache server with SSL inside a Docker container, making your local development environment secure and more aligned with production settings. This setup ensures that your development practices include necessary security measures right from the start.
This project is licensed under the MIT License - see the LICENSE file for details.
- ⭐ Give this repo a ⭐ star ⭐ at the top of the page
- 🐦 Follow me on X
- 📺 Subscribe to my Youtube channel