如何在lnmp上部署Thinkphp

如题所述

ThinkPHP的四种URL模式:0(普通模式);1(PATHINFO模式);2(REWRITE模式);3(兼容模式)nginx需要PATHINFO模式,但需要更改nginx配置文件让其支持PATHINFO模式。系统环境:系统:CentOS-6.4-x86_64web服务器:nginx1.2.7PHP版本:PHP5.3.17数据库版本:MySQL5.5.28一、安装LNMP1.0一键安装包按照以上版本安装环境二、修改配置文件1.修改php配置文件php.ini,将其中cgi.fix_pathinfo=0,值改为1重启php-fpm2.ssh里执行:cat>/usr/local/nginx/conf/pathinfo.conf<<'EOF'set$real_script_name$fastcgi_script_name;if($fastcgi_script_name~"(.+?\.php)(/.*)"){set$real_script_name$1;set$path_info$2;}fastcgi_paramSCRIPT_FILENAME$document_root$real_script_name;fastcgi_paramSCRIPT_NAME$real_script_name;fastcgi_paramPATH_INFO$path_info;EOF再将虚拟主机配置文件里的location~.*\.(php|php5)?$替换为:location~.*\.php再在includefcgi.conf;下面添加一行includepathinfo.conf;重启nginx完整的虚拟主机配置文件如下:server { listen 80; server_namewww.lnmp.org; indexindex.htmlindex.htmindex.php; root /home/wwwroot/lnmp; location~.*\.php { try_files$uri=404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_indexindex.php; includefcgi.conf; includepathinfo.conf; } location/status{ stub_statuson; access_log off; } location~.*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location~.*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/lnmp.log lnmp;}将ThinkPHP的URL模式设置成PATHINFO。ThinkPHP就可以在nginx中运行了。
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答