저는 nginx를 처음 사용하지만 종교적으로 모든 튜토리얼을 따르고 WordPress 사이트를 설정하려고 시도했지만 현재 해결할 수 없는 문제가 있습니다. 기본적으로 내 WordPress 사이트의 구성 파일에는 다음과 같은 구성이 있습니다.
server {
listen 80;
listen 443 default ssl;
server_name domain.com;
root /var/www/html/domain.com/htdocs;
access_log /var/www/html/domain.com/htdocs/logs/access.log;
error_log /var/www/html/domain.com/htdocs/logs/error.log;
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
rewrite /files/$ /index.php last;
if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}
location ~* ^/(favicon.ico|robots.txt)$ {
access_log off;
log_not_found off;
}
location ~ .php$ {
try_files $uri =404;
# Include the fastcgi_params defaults provided by nginx
include /etc/nginx/fastcgi_params;
# SCRIPT_FILENAME is a required parameter for things to work properly,
# but is missing in the default fastcgi_params. We define it here to
# be sure that it exists.
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /var/www/html/domain.com/htdocs$fastcgi_script_name;
# Use the upstream for fastcgi / php5-fpm that we defined in nginx.conf
fastcgi_pass php;
# And get to serving the file!
fastcgi_index index.php;
}
}
IP 주소/domain.com을 입력하면 약간의 지연이 발생하고 사이트 텍스트만 표시됩니다. 오류가 없으며 실제로 페이지가 렌더링되지 않는 것과 거의 같습니다. PHP가 제대로 구문 분석되지 않기 때문입니까? 그렇지 않으면 내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니까?
답변1
PHP를 처리하도록 nginx를 구성하지 않은 것 같습니다. 확인해 보세요이것답변.