[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、pip、anaconda安装的一些记录

    写这篇博客是因为自己这段时间总是倒腾python的环境,其间倒腾崩了好几次.....无奈之下还是梳理一下. PYTHON 首在安装python3.6的之后,我安装了anaconda3,这样我的电脑上p ...

  2. 环境配置 python 3.6+Anaconda+cuda9.0+cudNN7.0+Tensorflow

    最近在摸deepfakes代码,一堆环境要配置,过程记录一下吧. 一.安装Python3.6 Ubuntu16.04系统下默认是python2.7.网上说一般不建议卸载系统自带的python,所以保留 ...

  3. Linux 中ifconfig和ip addr命令看不到ip

    解决方案: 输入 vi /etc/sysconfig/network-scripts/ifcfg-ens33 将ONBOOT权限改为yes 保存退出,按Esc,输入:wq 重启网络服务,输入 sudo ...

  4. NIO(2):Channel

    Channel可以理解为铁轨,Buffer是铁轨上的火车.铁轨的两端连接这文件描述符或者说文件的缓冲区和程序运行时的内存.借助NIO是一种更加符合OS底层文件系统的调用方式,使用NIO可以用更小的开销 ...

  5. 生物网络,RNA 与疾病关联分析

    题目: 大数据时代下基于网络算法和机器学习的非编码RNA 相关预测研究摘要:最近越来越多的生物实验表明非编码RNA 具有非常重要的生物学功能,参与细胞中的多项重要生命活动,调控许多基本且重要的生物过程 ...

  6. vue页面跳转

    一.在template中的常见写法: <router-link to="/recommend"> <button class="button" ...

  7. iOS 简化冗余代码

    正在给深圳某家智能家居开发iPad版本,在已经存在的iPhone版上修改,该app的界面采用的是xib.xib相比代码来写界面,快速高效,但是可维护性和可读性太差.言归正传,看到这些代码后,我的心情很 ...

  8. 过滤器+用session验证是否登陆过

    过滤器: public class MyActionFilter : ActionFilterAttribute//继承ActionFilterAttribute类 { public override ...

  9. RabbitMQ java 原生代码

    rabbitMQ 的交换器有四种类型:direct.fanout.topic.headers 以下是具体的代码: direct:路由键只能全部匹配,才能进入到指定队列中.其他使用 direct生产者 ...

  10. 题解 洛谷P4779 【【模板】单源最短路径(标准版)】

    正权图,貌似看来是一道裸的 \(dijkstra\) \(dijkstra\)的主要步骤: 首先,在\(dijkstra\)中,源点表示一开始的出发点,蓝点表示还未确定的点,白点则表示已经确定的点. ...