企業實戰項目Linux+nginx+php+mysql+redis部署web服務2.0php
因爲公司開發使用的是thinkphp框架,以前文檔的nginx配置沒法很好的支持。html
若是你也遇到這個問題那麼將你的nginx.conf修改成以下mysql
注意:如下配置加在 server{}中nginx
location "/"的配置web
location / { root html; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
fastcgi配置redis
注意:若是你的fastcgi配置,location匹配寫的是 location ~ \.php$,須要把"$"去掉sql
location ~ \.php { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_cache cache_fastcgi; fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_cache_key http://$host$request_uri; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }