[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. ubuntu 16.04 循环登陆问题

    换了个titan x重装显卡驱动失败之后一直循环登陆,试了N种处理显卡驱动的方法,并没有啥用. 最后查看了一下.Xerrer文件(具体的文件名我给忘记了),发现是.Xauthority. 现象:在Ub ...

  2. node-red File读取好保存

    File节点是操作文件的节点 file文件的保存 拖拽 注入节点inject  file节点(writes msg.payload to a file)和 debug节点到工作区,并连线 设置file ...

  3. 缺陷的背后(三)---mysql之sql_mode为空的陷阱

    导语 mysql服务器可以在不同的sql_mode模式下运行,并且可以根据sql_mode系统变量的值,为不同的客户机应用不同的模式.sql_mode会影响mysql支持的sql语法,并且会执行数据验 ...

  4. java 堆 排序学习

    /** * <html> * <body> * <P> Copyright 1994 JsonInternational</p> * <p> ...

  5. winform实现图片的滑动效果

    使用winform实现图片的滑动效果(类似网站首页图片滑动切换效果),结果实现了,但是效果其实不是很理想.也许有更好的方法.         Timer timerSlide = null; //当前 ...

  6. 实现负载均衡的小demo

    首先我们先来了解负载均衡: 负载均衡是为了缓解网络压力的,服务器端进行扩容的重要手段 实现有两种方式:硬件F5    .   软件nginx.Dubbo 为了实现负载均衡的原理,我们基于以下两篇随笔继 ...

  7. HttpClinet工具类

    一.URL调用 忽略https证书 1.调用 InputStream in = null; try { URL url = new URL( "url地址" ); IgnoreSS ...

  8. 计算机网络原理,TCP&UDP

    UDP伪首部:计算校验和时会用到,然后实际传输过程中里包含的IP地址没有什么用. UDP校验和计算:求数值之和,如果溢出回卷,最后求出反码;UDP伪首部,UDP首部,应用层数据相加 tcp报文,最短2 ...

  9. django rest framework的viewset中关于ModelViewset的定义

    ---恢复内容开始--- viewset的关于ModelViewSet的定义是: class ModelViewSet(mixins.CreateModelMixin, mixins.Retrieve ...

  10. GCC 编译流程简介

    GCC-GCC编译流程 序言 对于大多数程序员而言,大家都知道gcc是什么,但是如果不接触到linux平台下的开发,鲜有人真正了解gcc的编译流程,因为windows+IDE的开发模式简直是一条龙全套 ...