我正在寻找如何允许symfony中的一个用户运行多个进程。 我在Symfony / Nginx / Php FPM中有此行为 但我在干净的symfony和php网络服务器中进行了测试:
composer create-project symfony/website-skeleton my-project
这是docker config:
version: "3.1"
services:
webserver:
image: nginx:alpine
container_name: viz-webserver
working_dir: /application
volumes:
- .:/application
- ./docker/nginx/nginx_all.conf:/etc/nginx/nginx.conf
networks:
itb_net:
ipv4_address: 10.2.0.6
php-fpm:
build: itb_docker/php-fpm
container_name: php-fpm
working_dir: /application
networks:
itb_net:
ipv4_address: 10.2.0.8
volumes:
- ~/.ssh/:/root/.ssh/
- .:/application
- ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
- ./.aws/credentials:/var/www/.aws/credentials
php-ini-overrides.ini
upload_max_filesize = 200M
post_max_size = 208M
memory_limit = 4048M
php-fpm Dockerfile
FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y --no-install-recommends install php-zip php-xdebug php-gd php-xml php7.2-mysql php7.2-intl php7.2-tidy php7.2-xmlrpc php7.2-soap php7.2-bcmath php-mbstring php-curl\
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install git
RUN apt-get update \
&& apt-get -y install git acl wkhtmltopdf xvfb \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
nginx
user nginx;
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
#sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
# limit_conn conn_limit_per_ip 10;
# limit_req zone=req_limit_per_ip burst=10 nodelay;
fastcgi_keep_conn on;
#proxy_buffering off;
gzip off;
listen 80 default;
client_max_body_size 208M;
access_log /var/log/nginx/application.access.log;
root /application/public;
rewrite ^/index\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# Deny all . files
location ~ /\. {
deny all;
}
location ~ ^/(index)\.php(/|$) {
fastcgi_pass php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index app_dev.php;
send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}
# Statics
location /(bundles|media) {
access_log off;
expires 30d;
try_files $uri @rewriteapp;
}}
}
测试控制器:
class TestController extends Controller
{
/**
* @Route("/test1")
*/
public function aAction(){
$i = 0;
while($i<50){
echo "$i<BR>";
$i++;
sleep(2);
}
}
/**
* @Route("/test2")
*/
public function bAction(){
return new Response('OK');
}
}
和相同的结果-转到第二个选项卡中的/ test1和test2 =第二个选项卡等待第一个完成。
答案 0 :(得分:3)
内置的PHP服务器是单线程的。如果收到长请求或挂起的请求,则在线程可以自由处理传入的请求之前,它将无法处理下一个请求。
按照http://php.net/manual/en/features.commandline.webserver.php
Web服务器仅运行一个单线程进程,因此如果请求被阻止,PHP应用程序将停止。