[nginx]nginx的一个奇葩问题 500 Internal Server Error

解决方案

nginx 一直报500 Internal Server Error 错误,配置是通过phpstudy2018站点域名管理生成的。

默认是  root   "D:\php\phpstudy\PHPTutorial\WWW\foxphp";

修改成这样就好了

root   "D:\\php\\phpstudy\\PHPTutorial\\WWW\\foxphp";

查找了很多资料,因为很奇葩,木有多少可供参考的,之前配置单斜杠一直木有问题,也找不到为毛产生的。有人说是地址问题,或许是单斜杠被当成转义符号了吧,那就再加一个,然后就没有然后了,php网站可以通过域名正常访问了。

好吧,nginx我确实没有系统的从头到尾学习,一般能有就好。个人愚见,遇见了奇葩问题就记录了下来进行分享,或许能够给别人带来帮助。

server {
listen ;
server_name k.cn ;
root "D:\\php\\phpstudy\PHPTutorial\\WWW\\kppw";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
server {
listen ;
server_name t.cn ;
root "D:\\php\\phpstudy\PHPTutorial\\WWW\\thinkphp\\public";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
server {
listen ;
server_name o.cn ;
root "D:\\php\\phpstudy\PHPTutorial\\WWW\\opensns";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
server {
listen ;
server_name f.cn ;
root "D:\\php\\phpstudy\\PHPTutorial\\WWW\\foxphp";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
server {
listen ;
server_name abc.cn;
root "D:\\php\\phpstudy\\PHPTutorial\\WWW\\test";
location / {
index index.html index.htm index.php;
autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

linux-lnmp-nginx 配置

server
{
listen ;
#listen [::]:;
server_name l.cn *.l.cn;
index index.html index.htm index.php default.html default.htm default.php;
root /home/landv/php/fastadmin-weike/public; include rewrite/thinkphp.conf;
#error_page /.html; # Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php-pathinfo.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /.well-known {
allow all;
} location ~ /\.
{
deny all;
} access_log /home/wwwlogs/l.cn.log;
}

出现当前权限不足,无法写入配置文件application/database.php解决方法

/user/local/nginx/conf/fastcgi.conf简单粗暴修改这个文件

把fastcgi_param PHP_ADMIN_VALUE值修改即可

fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/landv/php/fastadmin-weike/:/tmp/:/proc/";

lnmp集成环境默认在最后一行。

因为lnmp默认会在虚拟主机目录创建一个.user.ini文件里面保存的是虚拟主机根目录配置信息

#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root:/tmp/:/proc/" ;

这个可以注释掉他。好吧坑那么多。

还会出现其他文件权限问题,反正测试使用直接给到最大权限,正式使用的时候,只能给部分目录开放权限。

chmod -R 777 *

lnmp .user.ini文件无法删除解决方法

使用命令lnmp vhost del删除虚拟主机后,需要使用ftp或者rm命令删除网站目录,但是却发现网站目录下有个文件.user.ini文件没有自动删除,出现提示rm: cannot remove `http://xxx.com/.user.ini’: Operation not permitted,连手动ftp也无法删除。

问题分析:根据上面的提示判断文件权限已经被锁定,需要先解除锁定。

问题解决:输入以下命令

chattr -i /home/wwwroot/你的网站目录/.user.ini

然后再用rm -rf命令或者FTP去删除就可以了。

隐藏thinkphp的index.php url,可以不用改成和官方的一样

修改lnmp的pathinfo.conf文件

fastcgi_split_path_info ^(.+?\.php)(/.*)$;

修改成
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;

thinkphp 隐藏index.php

server {
listen ;
server_name fast.cn ;
root "D:\\php\\phpstudy\\PHPTutorial\\WWW\\thinkphp\\fastadmin-weike\\public";
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$ last;
break;
}
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

真正起作用的是这一段配置:

if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$ last;
break;
}

[nginx]nginx的一个奇葩问题 500 Internal Server Error phpstudy2018 nginx虚拟主机配置 fastadmin常见问题处理的更多相关文章

  1. nginx提示:500 Internal Server Error错误的解决方法

    现在越来越多的站点开始用 Nginx ,("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 ...

  2. 【转】nginx提示:500 Internal Server Error错误的解决方法

    本文转自:http://www.jb51.net/article/35675.htm 现在越来越多的站点开始用 Nginx ,("engine x") 是一个高性能的 HTTP 和 ...

  3. Nginx频繁报“500 Internal Server Error”错误

    服务器导致访问量激增,频繁报"500 Internal Server Error"错误.我查了一下nginx的错误日志(apt-get方式安装的nginx的错误日志在/var/lo ...

  4. phpstudy 500 Internal Server Error 解决办法

    版本:phpstudy 2018 报错:500 Internal Server Error 原因:手动选择路径的时候,产生了斜杠不同  (正确:"D:/phpStudy/PHPTutoria ...

  5. POST 500 Internal Server Error

    今天调试公司web后台时发现一个POST 500 Internal Server Error的错误. 本来VS本地调试没有发现这个问题,然后发布到服务器时才出现了.然后找了好久没找到什么原因,再仔细在 ...

  6. 解决方案:安装wordpress出现500 Internal Server Error

    做一个资讯站点的时候遇到一个wordpress不知道算不算常见的问题:程序安装的时候提示500 Internal Server Error 那么最终百度谷歌找到以下解决方案: 安装新版本wordpre ...

  7. EBS Webservice Timeout,HTTP Server Return "500 Internal Server Error"

    http://blog.itpub.net/26687597/viewspace-1207571/ 基于Oracle EBS R12,开发了一个Webservice用于返回某项主数据,当请求的数据量非 ...

  8. python urllib2导出elasticsearch数据时 返回 "urllib2.HTTPError: HTTP Error 500: Internal Server Error"

    0.业务场景 将ES中某个index的某个字段的所有数据,导出到文件中 1.ES数据导出方法简述 ES数据导出方法,我主要找到了以下几个方面,欢迎大家补充: ES官方API:snapshot and ...

  9. < 配置jupyer notebook遇到的问题 - 500 : Internal Server Error >

    < anaconda配置jupyer notebook遇到的问题 - 500 : Internal Server Error > 问题描述: 我的jupyer notebook是在anac ...

随机推荐

  1. python实现scp功能

    最近公司有一个需求,需要把服务器A上的任务放到服务器B上,因为B上有HTTP,并且可以被外网访问,但是直接通过shell的scp,每次都需要输入密码.这里用python简单实现一下 直接上代码: im ...

  2. C# Attribute 名称和使用的问题

    如果定义Attribute时, 名字是以Attribute结尾的, 在使用的时候, 就可以省略Attribute, 直接写前面的名字, 但是这样真的好吗? 自以为帮程序员省了一个单词, 然而 真理不再 ...

  3. live555的使用(转载)

    Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现 了对多种音视频编码格式的音视频数据的流 ...

  4. MySQL Hardware--RAID卡BBU Learn Cycle

    RAID卡缓存策略 不同的RAID卡缓存策略对IO的性能影响较大,常见的策略有: 1.写操作策略,可设置为WriteBack或WriteThrough WriteBack:进行写操作时,将数据写入RA ...

  5. 传统Dolev-Yao攻击模型和eCK强安全模型之间的辨析

    1.DY模型是基于安全协议的分层次的思想,先考虑安全协议本身的行为逻辑是否存在缺陷,之后再考虑实现方法是否存在问题. 而在一般的协议分析中我 们在安全协议验证中我们假定攻击者不具备攻破密码算法的能力, ...

  6. TP5框架模块绑定二级域名

    application\config.php 修改 url_domain_deploy 为 true 'url_domain_deploy' => true application\route. ...

  7. QtCreator常用快捷键

    1)帮助文件:F1 (光标在函数名字或类名上,按 F1 即可跳转到对应帮助文档,查看其详细用法) 2).h 文件和对应.cpp 文件切换:F4 3)编译并运行:Ctrl + R 4)函数声明和定义(函 ...

  8. Locust 教程

    写在 Locust 教程开始的前面 本文参考了: Locust 教程 : https://www.axihe.com/tools/locust/home.html : locust 的官方 Githu ...

  9. linux系统编程之信号(四)

    今天继续探讨信号相关的东东,话不多说,正入正题: 信号在内核中的表示: 下面用图来进一步描述这种信号从产生到递达之间的状态(信号阻塞与未诀):   那是怎么来决定的呢?下面慢慢来举例分解: 所以,通过 ...

  10. deb: No command ‘deb’ found

    deb: No command ‘deb’ found Posted on September 19, 2010 Let’s take a simple example of running the ...