0%

解决wordpress的两个问题

2017年7月17日 下午5:19

问题

  1. WordPress提示“在裁剪您的图像时发生了错误”
  2. 解决wordpress修改固定连接后不能正常访问(404 or 有点尴尬诶!该页无法显示。)

问题1解决方法

  1. WordPress提示“在裁剪您的图像时发生了错误”的解决方法
  2. 以上的这篇文章用的是php5,而我用的是php7
  3. 我试了试sudo apt-get install php7-gd,但是会提示
    1
    2
    3
    4
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package php7-gd
  4. 于是我直接省了,用sudo apt-get install php-gd,成功了
  5. 然后sudo systemctl reload nginx,重启服务器

问题2的解决方法

  1. 修改nginx配置文件
  2. 在原来的基础上加上
    1
    2
    3
    location /wordpress {
    try_files $uri $uri/ /wordpress/index.php?$args;
    }
  3. 最后变成了
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    }

    location ~ \.php/ {
    if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    include snippets/fastcgi-php.conf;
    fastcgi_param SCRIPT_NAME $1;
    fastcgi_param PATH_INFO $2;
    fastcgi_param SCRIPT_FILENAME $document_root$1;
    }

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

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

    }
  4. 我参考的文章是nginx官方的针对wordpress的处理方法文章