CGI 是 Web Server 与后台语言交互的协议,有了这个协议,开发者可以使用任何语言处理 Web Server 发来的请求,动态的生成内容
FastCGI,顾名思义为更快的 CGI,它允许在一个进程内处理多个请求,而不是一个请求处理完毕就直接结束进程,性能上有了很大的提高。
FPM 是一个 PHP 进程管理器,包含 master 进程和 worker 进程两种进程
master
,6个worker
➜ ~ ps aux | grep php-fpm
root 22847 0.0 2.0 705156 80944 ? Ss 4月16 0:02 php-fpm: master process (/etc/php-fpm.conf)
www 22848 0.0 1.0 784796 42048 ? S 4月16 0:03 php-fpm: pool www
www 22849 0.0 1.0 711004 41772 ? S 4月16 0:03 php-fpm: pool www
www 22850 0.0 1.1 708916 43140 ? S 4月16 0:03 php-fpm: pool www
www 22851 0.0 1.1 782700 44876 ? S 4月16 0:04 php-fpm: pool www
www 22852 0.0 0.8 708800 34864 ? S 4月16 0:03 php-fpm: pool www
www 22871 0.0 1.1 782604 45856 ? S 4月16 0:03 php-fpm: pool www
server {
listen 443 http2 ssl;
server_name iluoy.com;
root /mnt/www/iluoy.com/public;
index index.php index.html index.htm;
# 省略ssl配置
location / {
concat on;
concat_max_files 30;
concat_unique off;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php last;
}
}
location ~ \.(js|css|png|jpg|jpeg|gif)$ {
expires off;
if (!-e $request_filename) {
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}