php 类
1. 2020/05/16 22:00:28 [error] 1710#0: *202 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/opt/www/zblog_repo/index.php) is not within the allowed path(s): (/opt/www/novel/:/tmp/:/proc/) in Unknown on line 0PHP message: PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0Unable to open primary script: /opt/www/zblog_repo/index.php (Operation not permitted)" while reading response header from upstream, client: 113.45.119.202, server: zblog.struggleyou.xin, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi-73.sock:", host: "zblog.struggleyou.xin"
出错分析:
(base) [root@????? logs]# /www/server/php/73/sbin/php-fpm -t
[16-May-2020 22:54:45] NOTICE: configuration file /www/server/php/73/etc/php-fpm.conf test is successful
(base) [root@????? logs]# ps -ef | grep php-fpm
root 1065 1 0 22:18 ? 00:00:00 php-fpm: master process (/www/server/php/73/etc/php-fpm.conf)
www 1066 1065 0 22:18 ? 00:00:00 php-fpm: pool www
www 1067 1065 0 22:18 ? 00:00:00 php-fpm: pool www
www 1068 1065 0 22:18 ? 00:00:00 php-fpm: pool www
www 1069 1065 0 22:18 ? 00:00:00 php-fpm: pool www
www 1070 1065 0 22:18 ? 00:00:00 php-fpm: pool www
www 1930 1065 0 22:32 ? 00:00:00 php-fpm: pool www
root 2018 1396 0 22:47 pts/0 00:00:00 grep --color=auto php-fpm
在这里再说一句,如果还是未能定位到问题,一定要多看日志出错提示,这将会对你排错有很大的帮助。
现在我给大家贴一下我服务器nginx的配置,大家可以根据自己的配置具体配置下:
nginx.conf
user www;
#user nobody;
#worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";
#pid logs/nginx.pid;
worker_processes 2;
error_log /opt/server/tengine/logs/error.log;
pid /opt/server/tengine/logs/nginx.pid;
# 单个进程最大的文件连接数
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
access_log "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=2G" main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
include /opt/server/tengine/conf/conf.d/*.conf;
}
fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
注意看fastcgi_param REDIRECT_STATUS 200; 这个是里面自带的 也就是代理内自带的。
novel_struggleyou.conf
server {
listen 80;
server_name novel.struggleyou.xin;
access_log logs/novel.struggleyou.xin.access.log main;
error_log logs/novel.struggleyou.xin.error.log;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name novel.struggleyou.xin;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;
### SSL cert files ###
ssl_certificate conf.d/cert/novel_cert/novel.struggleyou.xin.pem;
ssl_certificate_key conf.d/cert/novel_cert/novel.struggleyou.xin.key;
ssl_session_timeout 5m;
# index index.php index.html index.htm default.php default.htm default.html;
# root /opt/www/novel/public;
include conf.d/novel.loc;
}
novel.loc
root /opt/www/novel/public;
# 这里改动了 定义首页索引文件的名称
index index.php;
if (!-e $request_filename) { rewrite ^/(.*) /index.php?s=$1 last; }
location ~ \.php$ {
# root /opt/www/novel/public;
# fastcgi_pass 127.0.0.1:9000;
#fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_pass unix:/tmp/php-cgi-73.sock;
include fastcgi.conf;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "open_basedir=/opt/www/novel/:/tmp/:/proc/";
#fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#include fastcgi_params;
}
以下是我的具体树形目录
.
├── conf.d
│ ├── cert
│ │ ├── git_cert
│ │ ├── novel_cert
│ │ └── zblog_cert
│ ├── gogos_git_server.conf
│ ├── novel.loc
│ ├── novel_server.conf
│ ├── web.zip
│ ├── zblog.loc
│ └── zblog_server.conf
├── fastcgi.conf
├── fastcgi.conf.default
├── fastcgi_params
├── fastcgi_params.default
├── koi-utf
├── koi-win
├── mime.types
├── mime.types.default
├── nginx.conf
├── nginx.conf.bak
├── nginx.conf.default
├── proxy.conf
├── scgi_params
├── scgi_params.default
├── uwsgi_params
├── uwsgi_params.default
└── win-utf
python类:
1. -bash: */anaconda3/bin/conda: */anaconda3/bin/python: bad interpreter: No such file or directory
出错分析:
1. 目录移动,找不到文件执行。
a. 修改用户目录下的.vimrc文件,将文件路径修改为你要修改的路径
b. 修改anaconda3目录下的aconda python解析路径[/usr/local/anaconda3/bin/conda]
3. 注意修改完之后并不是马上就可以生效了,需要执行source [文件]
我这里执行了source /etc/profile 和source ~/.vimrc文件
最后,在这里,祝大家问题可以完美解决~ 我是小芝麻 如果可以帮到你,请点个赞哈! 如果还有问题,请留言提问!