V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
IssacTseng
V2EX  ›  NGINX

wordpress apache2 改成 nginx 了,出现问题

  •  1
     
  •   IssacTseng · 2017-03-15 17:38:53 +08:00 · 3252 次点击
    这是一个创建于 2560 天前的主题,其中的信息可能已经有所发展或是发生改变。

    进入首页打不开页面,下载一个没有文件名的文件。。。 但是其他页面,后台什么的都可以正常打开,求解如何修正。

    apache 已完全删除

    环境:

    MYSQL : 5.7.17 nginx/1.10.3 PHP 版本: 7.0.17-1+deb.sury.org~trusty+4

    18 条回复    2017-03-16 15:32:52 +08:00
    dot
        1
    dot  
       2017-03-15 18:42:34 +08:00
    上 nginx 的 server{}配置呀,要不谁知道什么问题。
    wssgcg1213
        2
    wssgcg1213  
       2017-03-15 19:04:51 +08:00
    楼上正解,配置文件
    frostfall
        3
    frostfall  
       2017-03-15 19:05:09 +08:00
    目测 nginx 有问题,我也是刚换到 mysql5.7 nginx1.10.2 php7 ,建议把 server{}贴上来帮你分析一下
    IssacTseng
        4
    IssacTseng  
    OP
       2017-03-15 19:38:33 +08:00
    server {
    listen 80 default_server;

    server_name 暂不公开;
    root /var/www/html;
    index index.php index.html index.htm;

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    location / {
    try_files $uri $uri/ /index.php?$args;
    }


    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
    }
    location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
    }


    location /phpmyadmin {
    root /var/www/html;
    index index.php;
    try_files $uri $uri/ =404;
    auth_basic "Verify identidy";
    auth_basic_user_file /var/www/html/phpmyadmin/.htpasswd;

    location ~ ^/phpmyadmin/(doc|sql|setup)/ {
    deny all;
    }
    location ~ /phpmyadmin/(.+\.php)$ {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
    }
    }

    }
    IssacTseng
        5
    IssacTseng  
    OP
       2017-03-15 19:39:01 +08:00
    @dot
    @wssgcg1213
    @frostfall
    感谢,求帮忙分析一下
    syuraking
        6
    syuraking  
       2017-03-15 20:42:20 +08:00
    location / {
    try_files $uri $uri/ /index.php?$args;
    }

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;


    wordpress 在 nginx 的基本不是这样么?
    abc123ccc
        7
    abc123ccc  
       2017-03-15 21:00:47 +08:00
    先把 phpmyadmin 所有相信息全部去掉看看正常不正常
    frostfall
        8
    frostfall  
       2017-03-16 10:04:12 +08:00
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    这里有问题
    去掉试试
    frostfall
        9
    frostfall  
       2017-03-16 10:07:27 +08:00
    location ~ /phpmyadmin/{}这里我觉得该加上 root 目录吧
    dot
        10
    dot  
       2017-03-16 10:07:32 +08:00   ❤️ 1
    呃,我试了你的代码, php 部分,是可以运行的。
    那么,你测试的时候,用了隐私模式吗?如果之前调试的时候出现把 php 直接下载的情况,貌似会有缓存这样的请求,调试的话,开一个隐私模式的窗口试试。
    frostfall
        11
    frostfall  
       2017-03-16 10:12:49 +08:00
    说实话我看了半天都不知道 wordpress 的 index.php 在哪里, phpmyadmind 的 index.php 又在哪里,从提供的 server{}来看, wordpress 和 phpmyadmin 的 root 目录都是 /var/www/html ,但 index.php 只有一个,我猜 Nginx 也很纠结吧
    frostfall
        12
    frostfall  
       2017-03-16 10:14:42 +08:00
    建议不同的项目放不同的目录和 server{},你这样放一块肯定出问题
    dot
        13
    dot  
       2017-03-16 10:24:33 +08:00
    貌似没必要写两次 root /var/www/html;
    在顶层有就可以了,也可以听楼上的,把 phpmyadmin 里面的 root /var/www/html; 去掉先。

    不过我想应该不是主因,如果是主因的话, nginx 会直接报错的。
    colordog
        14
    colordog  
       2017-03-16 10:40:16 +08:00
    重定向问题吧
    colordog
        15
    colordog  
       2017-03-16 10:40:34 +08:00
    楼主是不是开了重定向了
    IssacTseng
        16
    IssacTseng  
    OP
       2017-03-16 11:11:17 +08:00
    @dot 啊 感谢。。清理浏览器缓存神奇般的打开了。。。什么问题都没了。。
    IssacTseng
        17
    IssacTseng  
    OP
       2017-03-16 11:16:45 +08:00
    @frostfall 这个是 WP 固定连接要求这样写的,我是按照知识库复制进去的

    https://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks
    dot
        18
    dot  
       2017-03-16 15:32:52 +08:00
    @prinzchao 哈哈哈哈哈哈哈~ 这根本不是技术问题啊!调试东西要用隐私模式你不知道的么~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3654 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:53 · PVG 12:53 · LAX 21:53 · JFK 00:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.