How to correctly link php-fpm and Nginx Docker containers?

后端 未结 7 977
天涯浪人
天涯浪人 2020-12-02 04:20

I am trying to link 2 separate containers:

  • nginx:latest
  • php:fpm

The problem is that php scripts do not work. Perhaps the php-fpm config

7条回答
  •  暖寄归人
    2020-12-02 04:31

    For anyone else getting

    Nginx 403 error: directory index of [folder] is forbidden

    when using index.php while index.html works perfectly and having included index.php in the index in the server block of their site config in sites-enabled

    server {
        listen 80;
    
        # this path MUST be exactly as docker-compose php volumes
        root /usr/share/nginx/html;
    
        index index.php
    
        ...
    }
    

    Make sure your nginx.conf file at /etc/nginx/nginx.conf actually loads your site config in the http block...

    http {
    
        ...
    
        include /etc/nginx/conf.d/*.conf;
    
        # Load our websites config 
        include /etc/nginx/sites-enabled/*;
    }
    

提交回复
热议问题