私は 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を設定していないようです。これ答え。