douguan1887
2015-07-21 05:06
浏览 293
已采纳

在Nginx上安装Wordpress时出错

I'm trying to install a wordpress site in a Linux VPS with LEMP Setup. So far I've done setting up the wordpress files and setting ownership for nginx user/group on the WP directory/files, but when I go to the address to access the installation page for WP (https://domain.tld/wp-admin/install.php), I end up with a php file download instead.

Here's my virtual host configuration for the WP site:

server {
    listen 80;
    server_name domain.tld;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;

    ssl on;
    ssl_certificate /directory/to/crt;
    ssl_certificate_key /directory/to/key;
    
    server_name domain.tld;
    root /var/www/html/domain.tld;
    index index.php index.html index.htm;

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

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
           
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
       root /usr/share/nginx/html;
    }

    location ~ \.php$ {
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass unix:/var/run/php5-fpm.sock;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_index index.php;
       include fastcgi_params;
    }
}

EDIT: I tried it in Firefox, and it's acting differently than in Chrome. The install.php page instead ends up in an error page like this:

An error occurred.

Sorry, the page you are looking for is currently unavailable. Please try again later.

If you are the system administrator of this resource then you should check the > error log for details.

Faithfully yours, nginx.

</div>

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用LEMP安装程序在Linux VPS中安装wordpress站点。 到目前为止,我已经完成了在WP目录/文件上设置wordpress文件和设置nginx用户/组的所有权,但是当我去地址访问WP的安装页面时( https://domain.tld/wp-admin/install.php ),我最终得到了一个php文件下载。< / p>

这是WP站点的虚拟主机配置:

  server {
 
  
 listen 80; 
 
 server_name domain.tld; 
 
返回301 https:// $ server_name $ request_uri; 
 
} 
 
 
 
 
 
 
 {
 
 
 
听听443 ssl  ; 
 
 
 
 ssl on; 
 
 \ ssl_certificate / directory / to / crt; 
 
 \ ssl_certificate_key / directory / to / key; 
 
 
 
 
invice_name domain.tld; \  r 
 root /var/www/html/domain.tld;
 index index.php index.html index.htm; 
 
 
 
位置/ {
 
 \ try_files $ uri $ uri  / /index.php?q=$uri&$arg  s; 
 
} 
 
 
 
 rewrite / wp-admin $ $ scheme:// $ host $ uri / permanent; 
 
 
 
 error_page 404 /404.html; \\  
 error_page 500 502 503 504 /50x.html;

 location = /50x.html {
 
 root / usr / share / nginx / html; 
 
} 
 
  
 
位置〜\ .php $ {
 
 try_files $ uri = 404; 
 
 fastcgi_split_path_info ^(。+ \。php)(/。+)$; 
 
 
 fastcgi_pass unix:/ var  /run/php5-fpm.sock;
 fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; 
 
 fastcgi_index index.php; 
 
包括fastcgi_params; 
 
} 
 
}    
 
  
 
  
 
 
 
 

编辑:我在Firefox中试过它,它的行为与Chrome不同。 install.php页面最终会出现在这样的错误页面中:

发生错误。

抱歉,该页面 您正在寻找目前无法使用。 请稍后再试。

如果您是此资源的系统管理员,那么您应该检查&gt; 错误日志了解详情。

忠实于你,nginx。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyu9667 2015-07-21 11:11
    已采纳

    I got it working now. The error was on the virtual host's *.conf file. I got the directory for php-fpm sock wrong. So that was the reason the php is not working on the site, and instead just downloads the install.php file, and domain is ending up in error.

    fastcgi_pass unix:/var/run/php5-fpm.sock; <---- I just got the directory wrong on this one.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • doudou3935 2016-10-27 09:52

    Maybe just u forget to start your php-fpm

    cd /usr/local/php7-chanxiao/etc/                                
    

    ../sbin/php-fpm

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题