Coder Social home page Coder Social logo

nginx+PHP-FPM about docker-webserver HOT 15 CLOSED

nazar-pc avatar nazar-pc commented on September 2, 2024
nginx+PHP-FPM

from docker-webserver.

Comments (15)

nemozar avatar nemozar commented on September 2, 2024 1

problem in line fastcgi_param

with fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; work good.

in default config after pull line fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

phpMyAdmin is self-container, so despite it uses Apache, it is irrelevant here.

From the log it seems like you don't have 1.php file in there. I'm wondering why did you put root /data/nginx/www; in each location instead of directly under server.

You can try to see if the file is there by entering Nginx container and examining contents:

docker-compose exec nginx ls -al /data/nginx/www

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024

docker-compose exec nginx ls -al /data/nginx/www

drwxr-xr-x 2 git git 4096 Jun 7 06:56 .
drwxr-xr-x 5 git git 4096 Jun 7 06:00 ..
-rw-r--r-- 1 git git 5 Jun 7 06:02 1.html
-rw-r--r-- 1 git git 12 Jun 7 06:37 2.php
-rw-r--r-- 1 root root 90 Jun 7 06:00 index.html

in default config root set in each location.

1.html is well opened

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

Since files are in place and permissions are correctly it is purely Nginx configuration issue.
Did you restart Nginx after changing its configuration?

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

Wait, you have 1.html, but not 1.php

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024

Did you restart Nginx after changing its configuration?

i will stop docker-compose and docker-compose up after. if i comment location ~ \.php$ { then php file open for download.

Wait, you have 1.html, but not 1.php it is test. for all *.php files i get error. How for exists or not exists in server.

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024
server {
    listen       80;
    server_name  localhost;
    root   /data/nginx/www;
    location / {
        index  index.html index.htm;
    }
    location ~ \.php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }
}

current config

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

Can you post what is in logs when you try existing file, say, 2.php?
Because php_1 | 172.19.0.7 - 07/Jun/2017:07:39:58 +0000 "GET /1.php" 404 is actually correct answer for file that indeed doesn't exist.

You don't necessarily need to restart everything, you can just docker-compose restart nginx, since some other services like database might take longer and you shouldn't really wait for them as configuration is the same.

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024
drwxr-xr-x 2 git  git  4096 Jun  7 10:39 .
drwxr-xr-x 5 git  git  4096 Jun  7 06:00 ..
-rw-r--r-- 1 git  git     5 Jun  7 06:02 1.html
-rw-r--r-- 1 git  git     6 Jun  7 10:39 2.php
-rw-r--r-- 1 root root   90 Jun  7 06:00 index.html
-rw-r--r-- 1 git  git    12 Jun  7 06:37 index.php
php_1         | 172.19.0.7 -  07/Jun/2017:11:23:43 +0000 "GET /1.php" 404
php_1         | 172.19.0.7 -  07/Jun/2017:11:23:44 +0000 "GET /1.php" 404
php_1         | 172.19.0.7 -  07/Jun/2017:11:23:44 +0000 "GET /1.php" 404
php_1         | 172.19.0.7 -  07/Jun/2017:11:24:04 +0000 "GET /2.php" 404

when run docker-compose restart nginx

nginx_1       | 2017/06/07 06:31:48 [emerg] 1#1: unknown directive "server" in /data/nginx/config/conf.d/default.conf:1
nginx_1       | nginx: [emerg] unknown directive "server" in /data/nginx/config/conf.d/default.conf:1

config

server {
    listen       80;
    server_name  localhost;
    root   /data/nginx/www;
    location / {
        index  index.html index.htm;
    }
    location ~ \.php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }
}

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

Did you change anything in /data/nginx/config/nginx.conf? [emerg] unknown directive "server" doesn't make any sense.

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024

not problem with EOL. if i comment block with php and restart nginx file *.php dowloaded (config file is well)

in file /data/nginx/config/nginx.conf i set new config

server {
	listen       80;
	server_name  localhost;
	root   /data/nginx/www;
	location / {
		index  index.html index.htm;
	}
	location ~ \.php$ {
		fastcgi_pass   php:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
		include        fastcgi_params;
	}
}

in error.log nginx

2017/06/07 12:02:11 [error] 10#10: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.19.0.1, server: localhost, request: "GET /2.php HTTP/1.1", upstream: "fastcgi://172.19.0.6:9000", host: "localhost:81"

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

This is not a correct config if you put virtual host right into /data/nginx/config/nginx.conf (see https://stackoverflow.com/questions/10934705/unknown-directive-server-in-etc-nginx-nginx-conf4)

What I'd suggest you to do is to restore original /data/nginx/config/nginx.conf from /etc/nginx_dist/nginx.conf and put your virtual host into /data/nginx/config/conf.d/default.conf. If should work this way.

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

I do not change that particular line, it comes from base image. I typically replace the whole virtual host file with my own.

from docker-webserver.

nemozar avatar nemozar commented on September 2, 2024

Help me with php extension. How i understand me need instal in nazarpc/php:fpm container? but when i open him with exec bash and write apt-get install php-pgsql get error "Unable to locate package php-pgsql"

from docker-webserver.

nazar-pc avatar nazar-pc commented on September 2, 2024

This is a separate question and you should better ask it in separate issue so that it would be possible to to find it for other people.
The question about installing additional extensions was already asked here: #20

from docker-webserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.