0

I have set up a docker-compose.yml file to start a NGiNX server and serve PHP content, the thing is it keeps on showing the default NGiNX welcome page when I visit localhost:8080.

Here's my docker-compose.yml

version: "3"
services:
  web: 
    image: nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./public:/public
      - ./site.conf:/etc/nginx/conf.d/site.conf
    links:
      - php
  php:
    image: php:8-fpm
    volumes:
      - ./public:/public

And here's my site.conf

server {
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /public;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
2
  • 1
    Do you have an index.php file created? What do the logs say? Commented Feb 9, 2022 at 6:28
  • 1
    You might want to mount your config file as default.conf Commented Feb 9, 2022 at 6:36

1 Answer 1

1

If you have an index.php file inside the public folder, you just need to change the docker-compose.yml to:

volumes:
  - ./public:/public
  - ./site.conf:/etc/nginx/conf.d/default.conf
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.