启动项目过程记录
问题
可以访配置里root所定义的路径的.php文件除了index.php,但是当访问controller定义的路径时出现404
解决思路:查看错误日志,但错误日志没有更新 nginx.conf 配置文件后面加上错误权限等级 debug(最高级) 这样无论什么错误都会记录。
解决头脑风暴:可能是由于访问不了index.php 所致
问题 访问index.php提示 "PHP message: PHP Fatal error: Uncaught Error: Class ‘Yaf\Application’ not found in /home/thefair/www/eyepetizer_api/public/index.php:5
解决:
最后定位在php.ini上
添加如下:
yaf.use_spl_autoload = On
yaf.use_namespace = On
问题:后测试了php直接访问index.php,出现{“code”:40001,“message”:{“text”:“Illegal Request: Parameter missing, index”,“action”:“toast”},“result”:{}}
解决(终极方案):
彻底换掉nginx配置文件
配置文件详情见:
user www;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log debug;
#pid logs/nginx.pid;
events {
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;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;#可自定义
server_name 192.168.190.100;#可自定义
root /home/thefair/www/eyepetizer_api/public;#可自定义
#允许头部自定义header中带下划线
underscores_in_headers on;
#允许自定义header
ignore_invalid_headers off;
#允许客户端请求的最大单文件字节数
client_max_body_size 10m;
gzip on;
gzip_min_length 1k;
gzip_buffers 256 64k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss application/json;
gzip_vary on;
if ( $request_method !~ GET|POST|HEAD|OPTIONS ) {
return 403;
}
proxy_buffers 64 4k;
location / {
index index.php;
if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
}
location ~ (\.php|\.inc)$ {
fastcgi_pass 127.0.0.1:9000;#可自定义端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 256 128k;
chunked_transfer_encoding on;
include fastcgi_params;
fastcgi_read_timeout 300;
}
location /favicon.ico {
log_not_found off;
access_log off;
}
}
}
问题:访问/system/common/init 可以访问,但是其他的都重定向了。
未完待续!!!!