将项目放置到nginx后的default.confde 配置
配置之前最好把php的错误提示开启:
网址:https://blog.csdn.net/awake720/article/details/80466858
打开/etc/nginx/conf.d/default.conf
server
{
listen 80;//监听端口
server_name www.xx.com;#定义使用www.xx.com访问
#定义服务器的默认网站根目录位置,如果是直接使用域名返问.html的话root的值就直接为 /usr/share/nginx/htm
root /usr/share/nginx/html/tp5/public/;
index index.php index.html index.htm; #定义首页索引文件的名称#默认请求
location / {
index index.php;
#对url后面/以外的内从进行临时重定向,字面意思就是把http://abc.com/xxx按http://abc.com/index.php/xxx来解析
if (!-e $request_filename){rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
#PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;#支持pathinfo设置
fastcgi_pass 127.0.0.1:9000;# nginx连接fastcgi的模式,这是使用ip连接
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#$document_root是值root的值
include fastcgi_params;
}
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#禁止访问 .htxxx 文件
#location ~ /\.ht {
# deny all;
# }
}
YiiyibaiIndex/basic/web