Eu configurei um servidor Amazon ec2 LEMP para o meu site de fotografia, que anteriormente estava no apache, com o qual estou muito mais familiarizado.
Eu tenho tudo funcionando geralmente ok, exceto para no diretório do blog. Os arquivos CSS e JS parecem ser servidos pelo PHP e têm o tipo de conteúdo text / html, por exemplo, aqui estão os cabeçalhos de resposta para a folha de estilo do meu tema ( /blog/wp-content/themes/twentyseventeen/style.css?ver=4.9.8
):
content-type: text/html
date: Fri, 26 Oct 2018 02:33:26 GMT
server: nginx/1.12.2
status: 200
x-powered-by: PHP/5.4.16
vs os cabeçalhos da minha própria folha de estilo ( /include/css/style.css
):
accept-ranges: bytes
cache-control: max-age=315360000
content-length: 34199
content-type: text/css
date: Fri, 26 Oct 2018 02:48:04 GMT
etag: "5b7f653b-8597"
expires: Thu, 31 Dec 2037 23:55:55 GMT
last-modified: Fri, 24 Aug 2018 01:54:03 GMT
server: nginx/1.12.2
status: 200
Eu li muitos tópicos que lidam com problemas muito semelhantes. No entanto, estou confuso porque meu problema está confinado ao diretório /blog/
.
Algumas das outras perguntas / respostas que li mencionaram security.limit_extensions
e, na verdade, a minha ( /etc/php-fpm.d/www.conf
) foi configurada da seguinte forma:
security.limit_extensions =
;security.limit_extensions = .php .php3 .php4 .php5 .ttf
eu mudei:
;security.limit_extensions =
security.limit_extensions = .php .php3 .php4 .php5 .ttf
e reiniciado o nginx via service nginx restart
- mas o problema ainda persiste ..
Não consigo imaginar o que estou perdendo .. Pronto para jogar a toalha e voltar para o apache ..: (
Alguém viu o que eu perdi?
UPDATE: arquivos de configuração
/etc/nginx/nginx.conf:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
#user ec2-user;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
client_max_body_size 2M;
include mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-available/mikewillisphotography.com.conf
server {
listen 80 default_server;
server_name www.mikewillisphotography.com mikewillisphotography.com;
return 301 https://www.mikewillisphotography.com$request_uri;
}
server {
listen 443 ssl http2;
server_name mikewillisphotography.com;
return 301 https://www.mikewillisphotography.com$request_uri;
}
server {
listen 443 ssl default_server;
server_name www.mikewillisphotography.com;
#server_name localhost;
include /etc/nginx/sites-available/includes/restrictions.conf;
include /etc/nginx/sites-available/includes/wordpress.conf;
# include /etc/nginx/sites-available/includes/php.conf;
ssl_certificate /etc/letsencrypt/live/mikewillisphotography.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mikewillisphotography.com/privkey.pem;
location /.well-known/acme-challenge {
#root /var/www/html/letsencrypt/wordpress/;
root /usr/share/nginx/sites/mikewillisphotography.com/htdocs/letsencrypt/wordpress/;
}
client_max_body_size 2M;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/sites/mikewillisphotography.com/htdocs;
index index.php index.html index.htm;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/sites/mikewillisphotography.com/htdocs;
}
location ~ \.php$ {
include /etc/nginx/sites-available/includes/php.conf;
}
}
/etc/nginx/sites-available/includes/php.conf
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#wordpress stuff
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
/etc/nginx/sites-available/includes/wordpress.conf
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ^~ /blog {
root /usr/share/nginx/sites/mikewillisphotography.com/htdocs;
index index.php index.html index.htm;
include /etc/nginx/sites-available/includes/php.conf;
rewrite /wp-admin$ $scheme://$host$uri/index.php?q=$1 permanent;
try_files $uri $uri/ @blog;
}
location @blog {
rewrite ^/blog(.*) /blog/index.php?q=$1;
}