CodeIgniter与nginx搭配
CodeIgniter与nginx配合时,经常会遇到这两个错误提示:
File not found No input file specified
这个错误跟path_info有关,需要在nginx中对应的站点配置中做简单配置。下面我把我的一个站点配置贴出来供参考:
server { listen 80; server_name services.xx.com; server_name_in_redirect off; root /data/web/xx/services; index index.php index.htm index.html; error_log /data/log/xx/web_common/error.log ; access_log /data/log/xx/web_common/access.log main; location / { index index.php index.html; } if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } location ~ .*\.(svn|git|cvs) { deny all; } location ~* \.(htm|html|xml|shtml)$ { expires 600; } location ~* \.(js|css|htc|gif|ico|png|swf|jpg|jpeg|bmp)$ { expires 365d; } location ~* \.(bak|tar|gz|zip|tgz|sql)$ { return 403; } location ~ .*.php($|/) { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; include php_fastcgi_params; fastcgi_pass unix:/tmp/php-fpm.sock; fastcgi_index index.php; } }
特别注意最后一个配置中的 fastcgi_split_path_info和 fastcgi_param PATH_INFO以及 location ~ .*.php($|/)。仔细对比自己的配置和我的配置吧。
对于有子站点的情况,比如我的CI目录结构是这样的:
---- application |---- api |---- wechat---- system---- logs……
application目录下放各个子站点,并通过同一个二级域名访问,假设是 apps.xx.com,那么各个子站点的访问链接为:
http://apps.xx.com/apihttp://apps.xx.com/wechat
那么,apps这个二级域名对应的配置为:
server { listen 80; server_name apps.xx.com; server_name_in_redirect off; root /data/web/xx/application; index index.php index.htm index.html; error_log /data/log/xx/web_common/error.log ; access_log /data/log/xx/web_common/access.log main; location / { index index.php index.html; } location /api { index index.php index.html; if ( !-e $request_filename ) { rewrite ^/api/(.+)$ /api/index.php/$1 last; break; } } location /wechat { index index.php index.html; if ( !-e $request_filename ) { rewrite ^/wechat/(.+)$ /wechat/index.php/$1 last; break; } } location ~ .*\.(svn|git|cvs) { deny all; } location ~* \.(htm|html|xml|shtml)$ { expires 600; } location ~* \.(js|css|htc|gif|ico|png|swf|jpg|jpeg|bmp)$ { expires 365d; } location ~* \.(bak|tar|gz|zip|tgz|sql)$ { return 403; } location ~ .*.php($|/) { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; include php_fastcgi_params; fastcgi_pass unix:/tmp/php-fpm.sock; fastcgi_index index.php; } }
注意各个子站点的配置。

PHP在現代編程中仍然是一個強大且廣泛使用的工具,尤其在web開發領域。 1)PHP易用且與數據庫集成無縫,是許多開發者的首選。 2)它支持動態內容生成和麵向對象編程,適合快速創建和維護網站。 3)PHP的性能可以通過緩存和優化數據庫查詢來提升,其廣泛的社區和豐富生態系統使其在當今技術棧中仍具重要地位。

在PHP中,弱引用是通過WeakReference類實現的,不會阻止垃圾回收器回收對象。弱引用適用於緩存系統和事件監聽器等場景,需注意其不能保證對象存活,且垃圾回收可能延遲。

\_\_invoke方法允許對象像函數一樣被調用。 1.定義\_\_invoke方法使對象可被調用。 2.使用$obj(...)語法時,PHP會執行\_\_invoke方法。 3.適用於日誌記錄和計算器等場景,提高代碼靈活性和可讀性。

Fibers在PHP8.1中引入,提升了並發處理能力。 1)Fibers是一種輕量級的並發模型,類似於協程。 2)它們允許開發者手動控制任務的執行流,適合處理I/O密集型任務。 3)使用Fibers可以編寫更高效、響應性更強的代碼。

PHP社區提供了豐富的資源和支持,幫助開發者成長。 1)資源包括官方文檔、教程、博客和開源項目如Laravel和Symfony。 2)支持可以通過StackOverflow、Reddit和Slack頻道獲得。 3)開發動態可以通過關注RFC了解。 4)融入社區可以通過積極參與、貢獻代碼和學習分享來實現。

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

PHP不是在消亡,而是在不斷適應和進化。 1)PHP從1994年起經歷多次版本迭代,適應新技術趨勢。 2)目前廣泛應用於電子商務、內容管理系統等領域。 3)PHP8引入JIT編譯器等功能,提升性能和現代化。 4)使用OPcache和遵循PSR-12標準可優化性能和代碼質量。

PHP的未來將通過適應新技術趨勢和引入創新特性來實現:1)適應云計算、容器化和微服務架構,支持Docker和Kubernetes;2)引入JIT編譯器和枚舉類型,提升性能和數據處理效率;3)持續優化性能和推廣最佳實踐。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

禪工作室 13.0.1
強大的PHP整合開發環境

WebStorm Mac版
好用的JavaScript開發工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3 Linux新版
SublimeText3 Linux最新版

記事本++7.3.1
好用且免費的程式碼編輯器