Client Area

 Client Area

How to install PHP 7.1 or PHP 7.2 with EasyEngine

Sections

    Install php7.1-fpm and/or php7.2-fpm

    On debian 8 Jessie only, add the deb sury repository before installing php7.x

    apt-get install apt-transport-https lsb-release ca-certificates
    wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
    apt-get update

    Then install the php release of your choice

     # php7.1-fpm
    apt update && apt install php7.1-fpm php7.1-cli php7.1-zip php7.1-opcache php7.1-mysql php7.1-mcrypt php7.1-mbstring php7.1-json php7.1-intl \
    php7.1-gd php7.1-curl php7.1-bz2 php7.1-xml php7.1-tidy php7.1-soap php7.1-bcmath -y
    
    # php7.2 fpm
    apt update && apt install php7.2-fpm php7.2-xml php7.2-bz2  php7.2-zip php7.2-mysql  php7.2-intl php7.2-gd php7.2-curl php7.2-soap php7.2-mbstring -y

    Configuration

    Option 1) Using the preconfigured files available on our Github repository

    To make the configuration of php7.1-fpm or php7.2-fpm easier, we have uploaded all our configuration files on our Github repository.
    This way, you can download them directly from your server to use php7.1-fpm or php7.2-fpm.

    To download our preconfigured files, use the following commands :

     # php7.1-fpm pool configuration
    wget -O /etc/php/7.1/fpm/pool.d/www.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.1/fpm/pool.d/www.conf
    service php7.1-fpm restart
    
    # php7.2-fpm pool configuration
    wget -O /etc/php/7.2/fpm/pool.d/www.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/php/7.2/fpm/pool.d/www.conf
    service php7.2-fpm restart
    
    # nginx upstream configuration 
    wget -O /etc/nginx/conf.d/upstream.conf https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/etc/nginx/conf.d/upstream.conf
    service nginx reload
    
    # EasyEngine common nginx configurations
    cd /etc/nginx/common
    wget https://raw.githubusercontent.com/VirtuBox/ubuntu-nginx-web-server/master/common.zip
    
    # if unzip isn't installed on your server
    apt install unzip -y
    
    unzip common.zip

    Then to use php7.1-fpm or php7.2-fpm, follow the steps listed in the Configure your vhost with php7.1-fpm or php7.2-fpm


    Option 2) Configure manually php7.1-fpm/php7.2-fpm

    Copy the pool configuration from php7.0-fpm

    # php7.1-fpm
    cp -f /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.1/fpm/pool.d/www.conf
    
    # php7.2-fpm
    cp -f /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.2/fpm/pool.d/www.conf
    

    Edit the listening port of php7.1-fpm or php7.2-fpm(for example, use 9080 instead of 9070)

    Example for /etc/php/7.1/fpm/pool.d/www.conf

    [www]
    user = www-data
    group = www-data
    listen = 127.0.0.1:9080
    listen.owner = www-data
    listen.group = www-data
    pm = ondemand
    pm.max_children = 100
    pm.start_servers = 20
    pm.min_spare_servers = 10
    pm.max_spare_servers = 30
    ping.path = /ping
    pm.status_path = /status
    pm.max_requests = 500
    request_terminate_timeout = 300

    Example for /etc/php/7.2/fpm/pool.d/www.conf

    [www]
    user = www-data
    group = www-data
    listen = 127.0.0.1:9090
    listen.owner = www-data
    listen.group = www-data
    pm = ondemand
    pm.max_children = 100
    pm.start_servers = 20
    pm.min_spare_servers = 10
    pm.max_spare_servers = 30
    ping.path = /ping
    pm.status_path = /status
    pm.max_requests = 500
    request_terminate_timeout = 300

    Then restart php-fpm

    # php7.1-fpm
    service php7.1-fpm restart 
    
    # php7.2-fpm
    service php7.2-fpm restart

    Adding php7.1-fpm or php7.2-fpm

    Option 1 : Replacing php7.0-fpm by php7.1-fpm/php7.2-fpm

    In this case, you just have to edit the file /etc/nginx/conf.d/upstream.conf and to replace the port for the upstream php7.
    So instead of server 127.0.0.1:9070; it will be server 127.0.0.1:9080; for php7.1-fpm or server 127.0.0.1:9090; for php7.2-fpm.

    Reload nginx to apply the configuration

    nginx -t
    service nginx reload
    Option 2 : Running php7.1-fpm/php7.2-fpm in addition to php7.0-fpm

    With EasyEngine, you can use a different php version for each website.

    To add php7.1-fpm or php7.2-fpm in addition to php7.0-fpm, the first step is to add them in the upstream list.

    Edit the file /etc/nginx/conf.d/upstream.conf, and add your new upstream :

    # php7.1-fpm
    upstream php71 {
    server 127.0.0.1:9080;
    
    # php7.2-fpm
    upstream php72 {
    server 127.0.0.1:9090;
    }

    Then to be able to use this new upstream, you have to make a copy of each php7.conf file located in /etc/nginx/common.
    For example, for php7.1-fpm, you have to copy php7.conf into php71.conf, locations-php7.conf into locations-php71.conf etc …
    And in each new .conf file, find and replace the line fastcgi_pass php7; by fastcgi_pass php71; for php7.1-fpm or fastcgi_pass php72; for php7.2-fpm.


    Configure your vhost with php7.1-fpm or php7.2-fpm

    To use php7.1-fpm or php7.2-fpm for your website, you just have to edit your vhost and to replace the configuration files used by EasyEngine.
    You can edit your vhost directly with nano/vi/vim or with the command ee site edit yourdomain.tld.
    You will find the following lines at the end of your vhost configuration :

        include common/php7.conf;
    
        include common/wpcommon-php7.conf;
        include common/locations-php7.conf;

    Just replace them with :

    # for php7.1-fpm
        include common/php71.conf;
    
        include common/wpcommon-php71.conf;
        include common/locations-php71.conf;
    
    # for php7.2-fpm
        include common/php72.conf;
    
        include common/wpcommon-php72.conf;
        include common/locations-php72.conf;

    Just reload nginx to apply the new configuration.

    in EasyEngine

    Feedback