[{"data":1,"prerenderedAt":137},["ShallowReactive",2],{"\u002F2015-03-28-ubuntu%E4%B8%8Blnmp%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEphalconphp":3},{"id":4,"title":5,"body":6,"date":113,"description":12,"extension":114,"meta":115,"navigation":118,"path":130,"seo":131,"stem":132,"tags":133,"__hash__":136},"blogs\u002F_legacy\u002F2015\u002F2015-03-28-ubuntu%e4%b8%8blnmp%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%aephalconphp.md","Ubuntu下Lnmp环境安装配置PhalconPHP",{"type":7,"value":8,"toc":109},"minimark",[9,13,16,19,22,33,36,42,45,51,54,57,60,67,70,80,91,97,100,106],[10,11,12],"p",{},"Lnmp在快速搭建网站环境方面特别方便，基本不用自己去研究各个软件的安装和配置。由于对Linux半生不熟，在安装Phalcon时却遇到了一些问题，在这里总结下经验。",[10,14,15],{},"当前Lnmp版本:1.1。当前Phalcon版本:1.3.4。PHP版本：5.6.6。",[10,17,18],{},"要使用PhalconPHP，升级下php版本比较好，按照lnmp官方的提示进行即可。",[10,20,21],{},"Phalcon的缓存系统可以使用Memcache，在升级了php版本之后，如果使用官方的安装脚本会有问题。将原本从48行开始的版本检测语句添加新的php版本即可：",[23,24,29],"pre",{"className":25,"code":27,"language":28},[26],"language-text","if echo \"$cur_php_version\" | grep -q \"5.2.\" \nthen \nsed -i 's#extension_dir = \".\u002F\"#extension_dir = \"\u002Fusr\u002Flocal\u002Fphp\u002Flib\u002Fphp\u002Fextensions\u002Fno-debug-non-zts-20060613\u002F\"\\nextension = \"memcache.so\"\\n#' \u002Fusr\u002Flocal\u002Fphp\u002Fetc\u002Fphp.ini \nelif echo \"$cur_php_version\" | grep -q \"5.3.\" \nthen \nsed -i 's#extension_dir = \".\u002F\"#extension_dir = \"\u002Fusr\u002Flocal\u002Fphp\u002Flib\u002Fphp\u002Fextensions\u002Fno-debug-non-zts-20090626\u002F\"\\nextension = \"memcache.so\"\\n#' \u002Fusr\u002Flocal\u002Fphp\u002Fetc\u002Fphp.ini \nelif echo \"$cur_php_version\" | grep -q \"5.4.\" \nthen \nsed -i 's#extension_dir = \".\u002F\"#extension_dir = \"\u002Fusr\u002Flocal\u002Fphp\u002Flib\u002Fphp\u002Fextensions\u002Fno-debug-non-zts-20100525\u002F\"\\nextension = \"memcache.so\"\\n#' \u002Fusr\u002Flocal\u002Fphp\u002Fetc\u002Fphp.ini \nelif echo \"$cur_php_version\" | grep -q \"5.6.\" \nthen \nsed -i 's#extension_dir = \".\u002F\"#extension_dir = \"\u002Fusr\u002Flocal\u002Fphp\u002Flib\u002Fphp\u002Fextensions\u002Fno-debug-non-zts-20131226\u002F\"\\nextension = \"memcache.so\"\\n#' \u002Fusr\u002Flocal\u002Fphp\u002Fetc\u002Fphp.ini \nelse \n&nbsp;&nbsp;&nbsp; echo \"Error: can't get php version!\" \n&nbsp;&nbsp;&nbsp; echo \"Maybe your php was didn't install or php configuration file has errors.Please check.\" \n&nbsp;&nbsp;&nbsp; sleep 3 \n&nbsp;&nbsp;&nbsp; exit 1 \nfi\n","text",[30,31,27],"code",{"__ignoreMap":32},"",[10,34,35],{},"通过apt-get install php5-phalcon安装的Phalcon是编译给PHP5.4的，由于没有实际使用过所以也不知道该Phalcon的版本是多少。按照官方的要求进行编译安装：",[23,37,40],{"className":38,"code":39,"language":28},[26],"git clone --depth=1 git:\u002F\u002Fgithub.com\u002Fphalcon\u002Fcphalcon.git\n\ncd cphalcon\u002Fbuild\n\nsudo .\u002Finstall\n",[30,41,39],{"__ignoreMap":32},[10,43,44],{},"这个时候会遇到错误，大体意思是找不到php目录。打开install脚本进行编辑，在第64行按照提示添加php-config",[23,46,49],{"className":47,"code":48,"language":28},[26],"\u002Fusr\u002Flocal\u002Fphp\u002Fbin\u002Fphpize && .\u002Fconfigure  --with-php-config=\u002Fusr\u002Flocal\u002Fphp\u002Fbin\u002Fphp-config --enable-phalcon && make && make install && echo -e \"\\nThanks for compiling Phalcon!\\nBuild succeed: Please restart your web server to complete the installation\"\n",[30,50,48],{"__ignoreMap":32},[10,52,53],{},"这个时候安装就能正确进行了，安装完成之后在php.ini中添加",[10,55,56],{},"extension = phalcon.so",[10,58,59],{},"重置lnmp，在phpinfo()中就能看到Phalcon已经启用成功。",[10,61,62],{},[63,64],"img",{"alt":65,"src":66},"image","\u002Fwp-content\u002Fuploads\u002F2015\u002F03\u002Fimage_thumb.png",[10,68,69],{},"使用lnmp的添加域名脚本添加好之后，需要对生成的配置文件进行修改。如果处理不当将可能导致以下两种情况：",[71,72,73,77],"ol",{},[74,75,76],"li",{},"所有的控制器都无法访问，全部被当作index\u002Findex来处理",[74,78,79],{},"无法正常的通过get、getQuery等函数获取url参数，全部返回null",[10,81,82,83,90],{},"具体的设定可以参考官方的",[84,85,89],"a",{"href":86,"rel":87},"http:\u002F\u002Fdocs.phalconphp.com\u002Fzh\u002Flatest\u002Freference\u002Fnginx.html",[88],"nofollow","安装说明","进行，下面给出的是本次配置服务器所使用的配置。",[23,92,95],{"className":93,"code":94,"language":28},[26],"server \n    { \n        listen 80; \n        #listen [::]:80; \n        server_name www.xxxx.com xxxx.com; \n        index index.html index.htm index.php default.html default.htm default.php; \n        set $root_path '\u002Fhome\u002Fwwwroot\u002Fwww.xxxx.com\u002Fpublic'; \n        root $root_path;\n\n        location \u002F { \n            try_files $uri $uri\u002F \u002Findex.php?_url=$uri&$args; \n        }\n\n        location ~ \\.php$ { \n                try_files $uri =404; \n                fastcgi_split_path_info ^(.+\\.php)(\u002F.+)$; \n                fastcgi_pass  unix:\u002Ftmp\u002Fphp-cgi.sock; \n                fastcgi_index index.php; \n                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; \n                include fastcgi.conf; \n        }\n\n \n\n        location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$ \n        { \n            root          $root_path; \n            expires      30d; \n        }\n\n \n\n        location ~ .*\\.(js|css)?$ \n        { \n            root          $root_path; \n            expires      12h; \n        }\n\n        location ~ \u002F\\.ht { \n            deny all; \n        } \n    }\n",[30,96,94],{"__ignoreMap":32},[10,98,99],{},"同时对Router进行设置：",[23,101,104],{"className":102,"code":103,"language":28},[26],"$di->set('router', function () use($routes) {\n\n    $router = new \\Phalcon\\Mvc\\Router(); \n    $router->setUriSource(\\Phalcon\\Mvc\\Router::URI_SOURCE_SERVER_REQUEST_URI);\n\n    return $router; \n});\n",[30,105,103],{"__ignoreMap":32},[10,107,108],{},"上面的步骤完成后，Phalcon就已经能够正常的在Lnmp上运行了。",{"title":32,"searchDepth":110,"depth":111,"links":112},2,3,[],"2015-03-28","md",{"layout":116,"status":117,"published":118,"author":119,"author_login":120,"author_email":121,"author_url":122,"wordpress_id":123,"wordpress_url":124,"date_gmt":125,"excerpt":126},"post","publish",true,{"display_name":120,"login":120,"email":121,"url":122},"chaoshikari","chaoshikari@gmail.com","\u002F",1186,"\u002F\u002F?p=1186","2015-03-28 07:15:02 +0000",{"type":7,"value":127},[128],[10,129,12],{},"\u002F2015-03-28-ubuntu下lnmp环境安装配置phalconphp",{"title":5,"description":12},"_legacy\u002F2015\u002F2015-03-28-ubuntu%e4%b8%8blnmp%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%aephalconphp",[134,135],"phalcon","lnmp","HmJ18hPsIxa_Lbn8la3vHsHxD27rrcuuacqrFRuJL9I",1788763178825]