nginx does not show index php

Question:

So guys, I believe it's some configuration on the server that isn't showing the error page, I'm running a docker-compose that "uploads" a php, mysql and nginx container but when I access localhost I get the following error:

403 Forbidden

Here is the nginx configuration file:

server {
    listen 80;
    index index.php index.html;
    server_name localhost;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /code;

    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;
    }
}

And the docker-compose to get rid of curiosity:

version: '2'
services:
    web:
        image: nginx:latest
        ports:
            - "80:80"
        volumes:
            - ./code/public_html:/code
            - ./site.conf:/etc/nginx/conf.d/default.conf
        links:
            - php
    php:
        image: php7-custom-conf
        volumes:
            - ./code/public_html:/code
        links:
            - db
    db:
        image: mysql:5.7
        volumes:
        - "./.data/db:/var/lib/mysql"
        restart: always
        ports:
            - "3306:3306"
        environment:
         MYSQL_ROOT_PASSWORD: dbrootpass
         MYSQL_DATABASE: dbname
         MYSQL_USER: dbuser
         MYSQL_PASSWORD: dbpass

All help is welcome, it's the end of the semester and I really can't see the error, I appreciate it.

Answer:

Apparently it was a directory permission error, I managed to work around the problem using chmod 0755 ./code/public_html apparently the linux access settings only allowed my user, and with this command I release reading and writing to the file's owner, users of the same group and other users.

Sources: https://www.vivaolinux.com.br/artigo/Entendendo-as-permissoes-de-arquivos-(chmod)

https://stackoverflow.com/questions/47053456/nginx-not-showing-index-php/47055492#47055492

Scroll to Top
AllEscort