gpt4 book ai didi

wordpress - Nginx "auto .dev"设置无法正确加载 WordPress

转载 作者:行者123 更新时间:2023-12-03 17:50:23 26 4
gpt4 key购买 nike

按照本指南( http://blog.evan.pro/how-to-set-up-dynamic-virtual-hosts-for-web-development ),我正在尝试设置一个 localhost/nginx 配置,它允许我轻松运行环境而无需为每个环境添加单独的条目(在 dnsmasq 的帮助下)。
当我运行 nginx 并通过 sitename.dev 访问任一站点时,使用 WordPress 的站点似乎无法运行。我想我在 nginx 配置中缺少一些东西,

worker_processes  1;

error_log /usr/local/etc/nginx/logs/error.log debug;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

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 /usr/local/etc/nginx/logs/access.log main;

sendfile on;

keepalive_timeout 65;

index index.html index.php;

server {
listen 80;
server_name .dev;

# dynamic vhosts for development
set $basepath "/var/www";

set $domain $host;
if ($domain ~ "^(.*)\.dev$") {
set $domain $1;
}
set $rootpath "${domain}";
if (-d $basepath/$domain/public) {
set $rootpath "${domain}/public";
}
if (-d $basepath/$domain/httpdocs) {
set $rootpath "${domain}/httpdocs";
}
if (-d $basepath/$domain/web) {
set $rootpath "${domain}/web";
}
if (-f $basepath/$domain/index.php) {
set $rootpath $domain;
}
if (-f $basepath/$domain/index.html) {
set $rootpath $domain;
}

root $basepath/$rootpath;

# enable PHP
index index.php app.php index.html;
location / {
index index.php;
error_page 404 = @indexphp;
include /usr/local/etc/nginx/conf.d/php-fpm;
try_files $uri $uri/ /index.php?$args;
}
location @indexphp {
rewrite ^(.*)$ /index.php$1;
}
location ~ ^(.+\.php)(?:/.+)?$ {
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}

# block .ht* access
location ~ /\.ht {
deny all;
}
}
}

例如,访问 mynewproject.dev 给我一个 200 OK 但没有加载任何内容。访问不使用 WordPress(但使用 PHP 等服务器语言)的其他项目.dev,我看到该站点正确显示。

最佳答案

检查以下内容
1) 如果您在文件夹中使用了 wordpress,则必须将其附加到您设置的 $base 路径“/var/www”;
2)发布您的错误日志。

关于wordpress - Nginx "auto .dev"设置无法正确加载 WordPress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22810254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com