vmware-archive / tutorials

BSD 2-Clause "Simplified" License
63 stars 102 forks source link

phpfpm static files 404 #16

Open luxarbt opened 5 years ago

luxarbt commented 5 years ago

Can't access to static files, every files are in 404 and served as text/html

alemorcuq commented 5 years ago

Hi, @allrib.

Could you please provide some steps in order to reproduce the issue?

Regards, Alejandro

luxarbt commented 5 years ago

Hi @alemorcuq

I followed step by step this tutorial : https://docs.bitnami.com/kubernetes/how-to/deploy-php-application-kubernetes-helm/ .

When I attach a simple css file like that in php file :

My PHP file is 200 OK. My CSS, JS are in 404 error.

Regards, Alexis

alemorcuq commented 5 years ago

Hi, @allrib,

In which step of the tutorial does it happen? Are you building the docker image again after attaching your files?

luxarbt commented 5 years ago

@alemorcuq

The problem is at the end of tutorials,

I did docker build . -t MYUSERNAME/phpfpm-app:0.1.0 in tutorials/phpfpm-k8s/ after attaching my files and I launched helm install --set mariadb.mariadbRootPassword=DB_ROOTPASSWORD,mariadb.mariadbUser=DB_USERNAME,mariadb.mariadbPassword=DB_USERPASSWORD,mariadb.mariadbDatabase=DB_NAME --name phpfpm .

When I go to http://IP:PORT I get for example version.php 200 OK and test.css, test.js error 404

luxarbt commented 5 years ago

@alemorcuq

Another problem I think : css, jss files are finally served as text/html. Even though I obtain an error 200 on my statics files, they are interpreted as text/html. Can you take a look on that ?

Regards,

Alexis

alemorcuq commented 5 years ago

Hi, @allrib.

Static files need to be mounted to the nginx container and not to the php-fpm one. If you look at the nginx.conf. Looking at the nginx.conf file:

server {
    listen 0.0.0.0:80;
    server_name myapp.com;

    root /app;

    location / {
        index index.php;
    }

    location ~ \.php$ {
        # fastcgi_pass [PHP_FPM_LINK_NAME]:9000;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}

You will have to mount your static files to the /app directory of your nginx container.

zetas commented 4 years ago

You will have to mount your static files to the /app directory of your nginx container.

@alemorcuq Any idea how to do that?

alemorcuq commented 4 years ago

You will have to mount your static files to the /app directory of your nginx container.

@alemorcuq Any idea how to do that?

How are you deploying Nginx?

iamamjad commented 4 years ago
helm install --set mariadb.mariadbRootPassword=DB_ROOTPASSWORD,mariadb.mariadbUser=DB_USERNAME,mariadb.mariadbPassword=DB_USERPASSWORD,mariadb.mariadbDatabase=DB_NAME --name phpfpm .

when i enter this command it give me the following error

Error:unknown flag --name
carrodher commented 4 years ago

--name is not a valid flag in Helm 3, if you are using Helm 3 you don't need to use this flag, only provide the chart name: