Vesta: Add support php 5.6 and php 7.1

Created on 22 Jan 2017  路  41Comments  路  Source: serghey-rodin/vesta

Add support for php 5.6 and 7.1 on the same server, so you do not need to do anything manual and have to change the script.

By the way, Vesta is excellent panel, I even made a video in my language showing how to install how to use for the staff of my language to use.

Excellent!

feature request

Most helpful comment

I think it will be as selector
Multiple PHP

All 41 comments

+1

This is not supported yet officialy, is not easy to support in all systems, but I think developers working in it.

There are tutorrials in forum to do this job

I use in my servers

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

`sudo apt-get install php5.6 \
php5.6-common \
php5.6-cgi \
php5.6-json \
php5.6-redis \
php5.6-imagick \
php5.6-apcu \
php5.6-fpm \
php5.6-curl \
php5.6-mysql \
php5.6-gd \
php5.6-mcrypt \
php5.6-pgsql \
php5.6-sqlite3 \
php5.6-mbstring \
php5.6-dom \
php5.6-zip \
php5.6-intl \
php-memcached \
php5.6-dev

sudo apt-get install php7.0 \
php7.0-common \
php7.0-cgi \
php7.0-json \
php7.0-redis \
php7.0-imagick \
php7.0-apcu \
php7.0-fpm \
php7.0-curl \
php7.0-mysql \
php7.0-gd \
php7.0-mcrypt \
php7.0-pgsql \
php7.0-sqlite3 \
php7.0-mbstring \
php7.0-dom \
php7.0-zip \
php7.0-intl \
php7.0-dev

sudo apt-get install php7.1 \
php7.1-common \
php7.1-cgi \
php7.1-json \
php7.1-redis \
php7.1-imagick \
php7.1-apcu \
php7.1-fpm \
php7.1-curl \
php7.1-mysql \
php7.1-gd \
php7.1-mcrypt \
php7.1-pgsql \
php7.1-sqlite3 \
php7.1-mbstring \
php7.1-dom \
php7.1-zip \
php7.1-intl \
php7.1-dev
`

After configure /etc/php/5.6, /etc/php/7.0 and /etc/php/7.1

@emtudo which OS + version are you running?

debian/ubuntu

Yes, but which version of Ubuntu of Debian?

Ubuntu 16.04.1

Thanks, now I can try it myself as I know I have the same OS :) are you using apache2 with nginx as proxy?

I do not use apache any longer.
Just use nginx

I use nginx to proxy and server http

I'm thinking of removing Apache as it drinks bottles of RAM :)

Let's keep this and issue related chat and don't talk about anything other than the issue

You will feel a big difference, nginx is very good, especially for sites with lots of hits.

thanks!

A selector would be nice to have, so to select different php versions for the sites, yes.

Doing manually right now. Installed 5.6, 7.0, and 7.1 as above with nginx->apache. Pick phpfcgid template. Just modify HOST/cgi-bin/fcgi-starter file:
from: exec /usr/bin/php-cgi
to: exec /usr/bin/php-cgi{5.6,7.0,7.1}

may require "service apache2 restart" if you already ran the site.

Maybe just add 3 more template options that just have different fcgi-starter? phpfcgi5.6, phpfcgi7.0, phpfcgi7.1

I'd imagine nginx and php-fpm would be slightly more complex especially if you want different pool for different user.

I already use manually as 3 versions, but not as form, and do not use apache, use only nginx.

I think it will be as selector
Multiple PHP

@emtudo How do you switch PHP Version on your Websites?

location ~ .php$ {
    include fastcgi_params;
    fastcgi_keep_conn on;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/run/php/php7.1-fpm-admin.sock;
}
location ~ .php$ {
    include fastcgi_params;
    fastcgi_keep_conn on;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/run/php/php5.6-fpm-admin.sock;
}

@emtudo Where do I make this changes? Sorry I'm kinda new on Server Management.

/home/admin/conf/web/nginx.conf
and
/home/admin/conf/web/snginx.conf

you need copy php pool /etc/php/VERSION/fpm/pool.d/www.conf to /etc/php/VERSION/fpm/pool.d/admin.conf

example:
/etc/php/7.1/fpm/pool.d/admin.conf

you need change "www" to "admin"
and "listen = /run/php/php7.1-fpm-admin.sock" same name to use in location

@emtudo but there is not any file called php7.1-fpm-admin.sock in /run/php/ and the website get 500 error.

you need restart php service:

cd /etc/init.d
./php7.1 restart

@emtudo I created this file /etc/php/7.1/fpm/pool.d/admin.conf
changed listen to /run/php/php7.1-fpm-admin.sock,
./php7.1-fpm restart
Still getting error 500 because there is not any file called php7.1-fpm-admin.sock in /run/php/

well, you need change user nginx:
/etc/nginx/nginx.conf
user root;
or
user admin;

or:
user YOU-USER;

PHP Version selector is critical table stakes in the web panel marketplace!
There should be support for the administrator to control the available versions to users.
And, if allowed by admin, allow the users to change their PHP version from those available.
Minimum would be per domain PHP version setting, but per directory would be very nice to have, even if it is configured through php.ini.

If it is so critical, why not make an effort yourself and share with others? Since Vesta is open source, everyone is able to contribute. Don't expect same maturity at once as commercial cPanel and Plesk which have been in the market for ages.

Creating website templates does the job excellent on my infrastructure. Just take a look at this walkthrough: http://forum.vestacp.com/viewtopic.php?f=19&t=10854

But I don't use nginx to serve dynamic content - I find it much more configurable under Apache.

As much as I would like to, unfortunately I don't have the skills to contribute that solution. I'm just offering my insights from many years of hosting websites and using a variety of control panels.

I used this: https://github.com/petranikin/mgrvphp
And works as charm. I already have php 5.5, 5.6 and 7 on the same Ubuntu server and no errors or issues so far.

@demlasjr Nginx+php-fpm?

@Ar1sC No, apache+nginx. I tried in nginx+php-fpm and I made it work perfectly. However, a lot of problems with php-fpm and also high CPU so I gone back to apache. Also, don't forget, if you have clients on the server, many of them have CMS, scripts or websites which doesn't work well without .htaccess and apache, so I recommend you apache+nginx instead.

Vesta supports php from the official distribution's repositories, and distro's maintainers take care of updating it, closing new vulnarabilities etc
If vesta makes a php version selector, there will be a lot of websites with phps with not closed vulnarabilities

These are widely accepted and supported repositories:

for Debian and Ubuntu:
https://www.dotdeb.org/

for CentOS and RHEL:
http://rpms.famillecollet.com/

Both provide PHP.

You may see implementations of these with docker here:
for PHP - https://github.com/stafli-org/stafli.language.php
for MariaDB - https://github.com/stafli-org/stafli.rdbms.mariadb

it's easy to copy the commands from the dockerfiles and reuse in shell or other scripts

I run nginx + apache with support of both fcgi and fpm through a docker container:

php-fpm
https://github.com/niiknow/vestacp/tree/458e2e1456a51ee7a0c3accca5649d2d85e43a75/rootfs/sysprepz/nginx-templates example https://github.com/niiknow/vestacp/blob/458e2e1456a51ee7a0c3accca5649d2d85e43a75/rootfs/sysprepz/nginx-templates/php-fpm.tpl

The implementation create dummy Apache template and use the _sh_ file to create php-fpm config.

https://github.com/niiknow/vestacp/tree/458e2e1456a51ee7a0c3accca5649d2d85e43a75/rootfs/sysprepz/apache2-templates

There are also fcgi templates in the link above. Currently implemented in a docker container on Ubuntu 16.04. I'm not sure if it'll work on other platforms but I can try to create a pull request if there are interests.

Example of how to select php-fpm templates inside of nginx + apache implementation: https://github.com/niiknow/vestacp/wiki/php-fpm-support

Alternatively, as these are just additional templates for Vesta, you can always download from my Github repo and push it to your local template directory: https://github.com/niiknow/vestacp/tree/master/rootfs/sysprepz/apache2-templates and https://github.com/niiknow/vestacp/tree/master/rootfs/sysprepz/nginx-templates

Of course, you will also need to already have installed all the required php-fpm support and modules.

Since Vesta is using Remi repo the correct way to replace current php version with php 7.0, 7.1 or 7.2 is:

Switch to 71 example:

yum-config-manager --enable remi-php71
yum update

Useful link

https://blog.remirepo.net/post/2018/01/04/PHP-version-5.6.33-7.0.27-7.1.13-and-7.2.1

Dotdeb for Debian/Ubuntu allows you to have multiple versions of PHP installed on your server.

Consider this setup script:

#!/bin/bash

# Repositories and keys
sudo add-apt-repository ppa:ondrej/php;
sudo apt-get update;

# Install software
sudo apt-get install -y php5.6-cli php5.6-xdebug php5.6-opcache php5.6-xml php5.6-json php5.6-soap php5.6-mbstring php5.6-mcrypt php5.6-gmp php5.6-curl php5.6-gd php5.6-imagick php5.6-ldap php5.6-redis php5.6-mysql php5.6-pgsql php5.6-sqlite3;
sudo apt-get install -y php7.0-cli php7.0-xdebug php7.0-opcache php7.0-xml php7.0-json php7.0-soap php7.0-mbstring php7.0-mcrypt php7.0-gmp php7.0-curl php7.0-gd php7.0-imagick php7.0-ldap php7.0-redis php7.0-mysql php7.0-pgsql php7.0-sqlite3;
sudo apt-get install -y php7.2-cli php7.2-xdebug php7.2-opcache php7.2-xml php7.2-json php7.2-soap php7.2-mbstring php7.2-gmp php7.2-curl php7.2-gd php7.2-imagick php7.2-ldap php7.2-redis php7.2-mysql php7.2-pgsql php7.2-sqlite3;
sudo apt-get install -y php-pear php-ssh2;

# Configure
sudo update-alternatives --set php $(which php7.0);

# Verifications
$(which php) -v;
$(which php5.6) -v;
$(which php7.0) -v;
$(which php7.2) -v;
$(which pecl) -V;
$(which pecl) list;

@lpalgarvio
it's not dotdeb, it's sury.org
dotdeb supports only 7.0, and has no plan to support 7.1 and 7.2

Why do you think that it's a good idea to add third party repositories out of the box?

Was this page helpful?
0 / 5 - 0 ratings