title: Can't incrase maximum opened files in PHP
body: <p>I have a website running php-fpm with nginx on ubuntu with socket system, when the site reach about 1000 users my socket throws an error and shuts down 
   I'm not sure if its system problem or PHP..</p>
  
  <blockquote>
    <p>Symfony\Component\Debug\Exception\ContextErrorException] Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024, but you have descriptors numbered at least as high as 1024. --enable-fd-setsize=2048 is recommended, but you may want to set it to equal the maximum number of open files supported by your system, in order to avoid seeing this error again at a later date.</p>
  </blockquote>
  
  <p>I have recompiled PHP with the following configurations - </p>
  
  <blockquote>
    <p>./configure \
            --enable-fpm \
            --enable-pdo \
            --with-pdo-mysql \
            --enable-sockets \
            --enable-exif \
            --enable-soap \
            --enable-ftp \
            --enable-wddx \
            --enable-pcntl \
            --enable-soap \
            --enable-bcmath \
            --enable-mbstring \
            --enable-dba \
            --enable-gd-native-ttf \
            --enable-zip \
            --enable-calendar \
            --with-mysql \
            --with-mysqli \
            --with-pdo-sqlite \
            --with-iconv \
            --with-zlib \
            --with-bz2 \
            --with-gettext \
            --with-xmlrpc \
            --with-openssl \
            --with-mhash \
            --with-mcrypt \
            --with-xsl \
            --with-curl \
            --with-pcre-regex \
            --with-gd \
            --with-freetype-dir=/usr \
            --with-jpeg-dir=/usr \
            --with-png-dir=/usr \
            --with-ldap \
            --with-pear \
            --with-fpm-user=www-data \
            --with-fpm-group=www-data \
            --with-config-file-path=/etc/php/ \
            --with-config-file-scan-dir=/etc/php/conf.d/ \
            --with-libdir=lib/x86_64-linux-gnu \
            --enable-fd-setsize=131072</p>
  </blockquote>
  
  <p>and set the same limit in bits/typesizes.h, linux/posix_types.h</p>
  
  <p>ulimit -Sn return 128000</p>
  
  <p>I have also edited the /etc/security/limits.conf with the following - </p>
  
  <blockquote>
    <p>www-data soft nofile 128000 </p>
    
    <p>www-data hard nofile 128000</p>
    
    <ul>
    <li><p>soft nproc 128000</p></li>
    <li><p>hard nproc 128000</p></li>
    <li><p>soft nofile 128000</p></li>
    <li><p>hard nofile 128000</p></li>
    </ul>
  </blockquote>
  
  <p>** EDIT 1 :** </p>
  
  <p>Just found out about a new way to check limit for specific process when I run 
  cat /proc/1719/limits (1719 is one of the nginx process)
  I get max open files soft limit 1024, hard limit 4096, I believe that’s what cause the issue, though I can't find how to raise it up..</p>
  
  <p>** EDIT 2 :**</p>
  
  <p>fixed that soft limit by adding ulimit -n 512000 to the run script (added it to both nginx and php-fpm), but still crush with same error.</p>