This repository contains the NGINX configuration for hosting multiple PHP applications on a single server using the wyveo/nginx-php-fpm Docker image with PHP 8.2. 🐳
The NGINX configuration is set up to listen on port 80 and handle multiple PHP applications, each located in a subdirectory. Key features include:
X-Frame-Options
,X-XSS-Protection
, andX-Content-Type-Options
headers for enhanced security.- Default charset set to UTF-8.
- Error page handling, redirecting 404 errors to the main index.php.
- Denying access to hidden files and directories.
- Custom error pages for favicon.ico and robots.txt.
The configuration includes settings for three PHP applications (app1
, app2
, and app3
). Each application block consists of:
- Alias to the respective application's public directory.
- Attempt to serve static files directly, falling back to the application's index.php if not found.
- Configuration for handling PHP files, forwarding requests to the PHP-FPM socket.
The Dockerfile is based on the wyveo/nginx-php-fpm image with PHP 8.2. It includes:
- Exposing port 80.
- Creating necessary directories for NGINX logs and web applications.
- Setting appropriate permissions for the web server to access directories.
-
Ensure Docker is installed on your system.
-
Clone this repository:
git clone https://github.com/vespidhook/nginx_mult_aplications_php_or_laravel.git
-
Navigate to the repository:
cd nginx_mult_aplications_php_or_laravel
-
Build the Docker image:
docker build -t your-image-name .
-
Run the Docker container:
docker run -p 8080:80 --name your-container-name -d your-image-name
Replace your-username
, your-repo
, your-image-name
, and your-container-name
with appropriate values.
Feel free to customize the NGINX configuration (default.conf
) or add more PHP applications following the established pattern.
This configuration is intended for development or educational purposes. For production use, consider enhancing security measures and adapting configurations based on specific requirements.
This NGINX PHP-FPM configuration is based on the wyveo/nginx-php-fpm image (PHP 8.2). Visit wyveo/nginx-php-fpm for more information about the base image.
This project is licensed under the MIT License - see the LICENSE file for details. 📜