在 Nginx 上安装 Wordpress 时出错
Error on Installing Wordpress on Nginx
我正在尝试使用 LEMP 安装程序在 Linux VPS 中安装一个 wordpress 站点。到目前为止,我已经在 WP directory/files 上设置了 wordpress 文件并设置了 nginx user/group 的所有权,但是当我转到地址访问 WP 的安装页面时(https://domain.tld/wp-admin/install.php ),我最终下载了 php 文件。
这是我的 WP 站点的虚拟主机配置:
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;
}
}
编辑:我在 Firefox 中尝试过,它的行为与在 Chrome 中不同。 install.php 页面反而以这样的错误页面结束:
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.
我现在开始工作了。错误出在虚拟主机的 *.conf 文件上。我把 php-fpm sock 的目录弄错了。所以这就是 php 无法在网站上运行的原因,而只是下载 install.php 文件,并且域最终出现错误。
fastcgi_passunix:/var/run/php5-fpm.sock; <---- 我只是把这个目录弄错了。
也许只是你忘了启动你的 php-fpm
cd /usr/local/php7-chanxiao/etc/
../sbin/php-fpm
我正在尝试使用 LEMP 安装程序在 Linux VPS 中安装一个 wordpress 站点。到目前为止,我已经在 WP directory/files 上设置了 wordpress 文件并设置了 nginx user/group 的所有权,但是当我转到地址访问 WP 的安装页面时(https://domain.tld/wp-admin/install.php ),我最终下载了 php 文件。
这是我的 WP 站点的虚拟主机配置:
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;
}
}
编辑:我在 Firefox 中尝试过,它的行为与在 Chrome 中不同。 install.php 页面反而以这样的错误页面结束:
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.
我现在开始工作了。错误出在虚拟主机的 *.conf 文件上。我把 php-fpm sock 的目录弄错了。所以这就是 php 无法在网站上运行的原因,而只是下载 install.php 文件,并且域最终出现错误。
fastcgi_passunix:/var/run/php5-fpm.sock; <---- 我只是把这个目录弄错了。
也许只是你忘了启动你的 php-fpm
cd /usr/local/php7-chanxiao/etc/
../sbin/php-fpm