Php Scripts on my Nginx / php7.2-fpm only working with the default config and the IP Adress not with Domain Names or subdomains...
My Configs:
Default Config
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
My Domain Config:
server {
listen 80;
listen [::]:80;
root /home/fluke667/html/web.mydomain.com/web;
index index.php index.html index.htm index.nginx-debian.html;
server_name web.mydomain.com;
location / {
try_files $uri $uri/ =404;
}
}
Nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
#default_type application/octet-stream;
default_type text/html;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Without that subdomain and with IP it works in /var/www/html Dont know why, can any1 Help me?
答案 0 :(得分:0)
以wordpress
的{{1}}编解码器为例
nginx
这意味着对于此 location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
块中的任何请求,最有可能将运行的第一个位置块。它将首先server
找到一个静态文件,然后尝试查找具有该请求路径的目录,然后最后将其发送到try
。发送到index.php
的第二个位置块将运行index.php
,它将把所有带有location ~ \.php$
文件扩展名的请求发送到php
您当前有2个php7.2-fpm.sock
块。 server
中有一个,Default Config
中有一个。您的自定义conf中有My Domain Config
,这意味着对该主机的任何请求都将由该server_name web.mydomain.com;
块来回答。其他任何主机都将由server
处理,其中包括IP。