Join the community today
Register Now

Custom php-fpm file

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by hardousse, Dec 15, 2017.

  1. hardousse

    hardousse Active Member

    123
    30
    28
    Dec 15, 2015
    Sweden
    Ratings:
    +45
    Local Time:
    7:39 PM
    1.11.*
    10.1*
    Please fill in any relevant information that applies to you:
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed:1.13.7
    • PHP Version Installed: 7.1
    • MariaDB MySQL Version Installed:10.1.21
    • When was last time updated Centmin Mod code base ? : Today
    Hi
    I want disabel /usr/local/nginx/conf/php.conf in nginx vhost and make custom pho-fpm specific for tapp how can make this .
    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    36,860
    8,068
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,426
    Local Time:
    3:39 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    1. make a copy of /usr/local/nginx/conf/php.conf i.e. as /usr/local/nginx/conf/php-tapp.conf
    Code (Text):
    cp -a /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/php-tapp.conf
    

    2. edit nginx vhost for site domain i.e. /usr/local/nginx/conf/conf.d/domain.com.conf or for https site at /usr/local/nginx/conf/conf.d/domain.com.ssl.conf and replace referenced include file to /usr/local/nginx/conf/php.conf with /usr/local/nginx/conf/php-tapp.conf
    3. restart nginx and php-fpm
    Code (Text):
    nprestart
    
     
  3. hardousse

    hardousse Active Member

    123
    30
    28
    Dec 15, 2015
    Sweden
    Ratings:
    +45
    Local Time:
    7:39 PM
    1.11.*
    10.1*
    Great
    Thank you for help
     
    • Like Like x 1
  4. eva2000

    eva2000 Administrator Staff Member

    36,860
    8,068
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,426
    Local Time:
    3:39 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    You're welcome
     
  5. hardousse

    hardousse Active Member

    123
    30
    28
    Dec 15, 2015
    Sweden
    Ratings:
    +45
    Local Time:
    7:39 PM
    1.11.*
    10.1*
    @eva2000 other question if you can ,I can use the same process for php-fpm pool?
     
  6. eva2000

    eva2000 Administrator Staff Member

    36,860
    8,068
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,426
    Local Time:
    3:39 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    similar process just php-fpm pool is in different directory so edit /usr/local/etc/php-fpm.conf and uncomment line removing semi-colon from from
    Code (Text):
    include=/usr/local/nginx/conf/phpfpmd/*.conf
    

    then php-fpm pool configs need to be placed in /usr/local/nginx/conf/phpfpmd/. There's already 4 extra php-fpm pools in that directory
    Code (Text):
    ls -lah /usr/local/nginx/conf/phpfpmd/
    total 32K
    drwxr-xr-x. 2 root root 4.0K Dec 11 08:42 .
    drwxr-xr-x. 6 root root  12K Dec 15 05:02 ..
    -rw-r--r--. 1 root root 1.7K Dec 11 08:42 phpfpm_pool2.conf
    -rw-r--r--. 1 root root 1.7K Dec 11 08:42 phpfpm_pool3.conf
    -rw-r--r--. 1 root root 1.7K Dec 11 08:42 phpfpm_pool4.conf
    -rw-r--r--. 1 root root 1.7K Dec 11 08:42 phpfpm_pool5.conf
    

    You can either edit one of these or create your own which maybe advisable if you don't need for centmin mod updates to overwrite the existing pools, so copy /usr/local/nginx/conf/phpfpmd/phpfpm_pool5.conf to /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf
    Code (Text):
    cp -a /usr/local/nginx/conf/phpfpmd/phpfpm_pool5.conf /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf
    

    then edit /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf changing listening port from 9005 to i.e. say 9006
    Code (Text):
    listen = 127.0.0.1:9006
    

    editing pool name from [pool5] to [pool6] and every reference in file for logs etc that mention pool5 to pool6

    you can use sed mass replacement
    Code (Text):
    sed -i 's|pool5|pool6|g' /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf
    

    use sdiff to check side by side the changes of original vs copied pool config
    Code (Text):
    sdiff -w160 -s /usr/local/nginx/conf/phpfpmd/phpfpm_pool5.conf /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf 
    

    output with original on left and custom php-fpm pool on right
    Code (Text):
    sdiff -w160 -s /usr/local/nginx/conf/phpfpmd/phpfpm_pool5.conf /usr/local/nginx/conf/phpfpmd/phpfpm_pool_tapp.conf
    [pool5]                                                                       | [pool6]
    ;listen = /tmp/php5-fpm-pool5.sock                                            | ;listen = /tmp/php5-fpm-pool6.sock
    slowlog = /var/log/php-fpm/www-slow-pool5.log                                 | slowlog = /var/log/php-fpm/www-slow-pool6.log
    pm.status_path = /phpstatus-pool5                                             | pm.status_path = /phpstatus-pool6
    ping.path = /phpping-pool5                                                    | ping.path = /phpping-pool6
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error-pool5.log         | php_admin_value[error_log] = /var/log/php-fpm/www-php.error-pool6.log
    

    then restart php-fpm + nginx
    Code (Text):
    nprestart
    
     
  7. hardousse

    hardousse Active Member

    123
    30
    28
    Dec 15, 2015
    Sweden
    Ratings:
    +45
    Local Time:
    7:39 PM
    1.11.*
    10.1*
    You are great
    Thank you
     
..