tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

phpfpm static files 404

Open luxarbt opened this issue 6 years ago • 10 comments

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

luxarbt avatar May 26 '19 12:05 luxarbt

Hi, @allrib.

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

Regards, Alejandro

alemorcuq avatar May 27 '19 09:05 alemorcuq

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

luxarbt avatar May 27 '19 11:05 luxarbt

Hi, @allrib,

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

alemorcuq avatar May 27 '19 11:05 alemorcuq

@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 avatar May 27 '19 11:05 luxarbt

@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

luxarbt avatar May 28 '19 07:05 luxarbt

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.

alemorcuq avatar Jun 03 '19 14:06 alemorcuq

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

@alemorcuq Any idea how to do that?

zetas avatar Nov 25 '19 18:11 zetas

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?

alemorcuq avatar Nov 26 '19 08:11 alemorcuq

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

iamamjad avatar Mar 15 '20 18:03 iamamjad

--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:

  • Random name:
▶ helm2 install .
▶ helm3 install --generated-name .
  • Defined name:
▶ helm2 install --name phpfpm .
▶ helm3 install phpfpm .

carrodher avatar Mar 16 '20 07:03 carrodher