I installed PHP 7 on CentOS 7 and ISPconfig 3.1 dev

Discussion in 'Installation/Configuration' started by cassola-enterprises, Aug 23, 2016.

  1. I did this:

    Code:
    mkdir -p /opt/php-7.0.9
    mkdir /usr/local/src/php5-build
    cd /usr/local/src/php5-build
    wget http://ca2.php.net/get/php-7.0.9.tar.bz2/from/this/mirror -O php-7.0.9.tar.bz2
    tar jxf php-7.0.9.tar.bz2
    
    cd php-7.0.9/
    
    yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel libc-client-devel postgresql-devel libxslt-devel
    
    ./configure --prefix=/opt/php-7.0.9 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=lib64 --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm
    
    make
    make install
    
    cp /usr/local/src/php5-build/php-7.0.9/php.ini-production /opt/php-7.0.9/lib/php.ini
    cp /opt/php-7.0.9/etc/php-fpm.conf.default /opt/php-7.0.9/etc/php-fpm.conf
    cp /opt/php-7.0.9/etc/php-fpm.d/www.conf.default /opt/php-7.0.9/etc/php-fpm.d/www.conf
    
    nano /opt/php-7.0.9/etc/php-fpm.conf
    [...]
    pid = run/php-fpm.pid
    [...]
    
    nano /opt/php-7.0.9/etc/php-fpm.d/www.conf
    [...]
    listen = 127.0.0.1:8999
    [...]
    
    nano /etc/init.d/php-7.0.9-fpm
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          php-7.0.9-fpm
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts php-7.0.9-fpm
    # Description:       starts the PHP FastCGI Process Manager daemon
    ### END INIT INFO
    php_fpm_BIN=/opt/php-7.0.9/sbin/php-fpm
    php_fpm_CONF=/opt/php-7.0.9/etc/php-fpm.conf
    php_fpm_PID=/opt/php-7.0.9/var/run/php-fpm.pid
    php_opts="--fpm-config $php_fpm_CONF"
    wait_for_pid () {
            try=0
            while test $try -lt 35 ; do
                    case "$1" in
                            'created')
                            if [ -f "$2" ] ; then
                                    try=''
                                    break
                            fi
                            ;;
                            'removed')
                            if [ ! -f "$2" ] ; then
                                    try=''
                                    break
                            fi
                            ;;
                    esac
                    echo -n .
                    try=`expr $try + 1`
                    sleep 1
            done
    }
    case "$1" in
            start)
                    echo -n "Starting php-fpm "
                    $php_fpm_BIN $php_opts
                    if [ "$?" != 0 ] ; then
                            echo " failed"
                            exit 1
                    fi
                    wait_for_pid created $php_fpm_PID
                    if [ -n "$try" ] ; then
                            echo " failed"
                            exit 1
                    else
                            echo " done"
                    fi
            ;;
            stop)
                    echo -n "Gracefully shutting down php-fpm "
                    if [ ! -r $php_fpm_PID ] ; then
                            echo "warning, no pid file found - php-fpm is not running ?"
                            exit 1
                    fi
                    kill -QUIT `cat $php_fpm_PID`
                    wait_for_pid removed $php_fpm_PID
                    if [ -n "$try" ] ; then
                            echo " failed. Use force-exit"
                            exit 1
                    else
                            echo " done"
                           echo " done"
                    fi
            ;;
            force-quit)
                    echo -n "Terminating php-fpm "
                    if [ ! -r $php_fpm_PID ] ; then
                            echo "warning, no pid file found - php-fpm is not running ?"
                            exit 1
                    fi
                    kill -TERM `cat $php_fpm_PID`
                    wait_for_pid removed $php_fpm_PID
                    if [ -n "$try" ] ; then
                            echo " failed"
                            exit 1
                    else
                            echo " done"
                    fi
            ;;
            restart)
                    $0 stop
                    $0 start
            ;;
            reload)
                    echo -n "Reload service php-fpm "
                    if [ ! -r $php_fpm_PID ] ; then
                            echo "warning, no pid file found - php-fpm is not running ?"
                            exit 1
                    fi
                    kill -USR2 `cat $php_fpm_PID`
                    echo " done"
            ;;
            *)
                    echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                    exit 1
            ;;
    esac
    
    
    chmod 755 /etc/init.d/php-7.0.9-fpm
    chkconfig php-7.0.9-fpm
    
    nano /lib/systemd/system/php-7.0.9-fpm.service
    [Unit]
    Description=The PHP 7 FastCGI Process Manager
    After=network.target
    
    [Service]
    Type=simple
    PIDFile=/opt/php-7.0.9/var/run/php-fpm.pid
    ExecStart=/opt/php-7.0.9/sbin/php-fpm --nodaemonize --fpm-config /opt/php-7.0.9/etc/php-fpm.conf
    ExecReload=/bin/kill -USR2 $MAINPID
    
    [Install]
    WantedBy=multi-user.target
    
    systemctl enable php-7.0.9-fpm.service
    systemctl daemon-reload
    
    systemctl start php-7.0.9-fpm.service
    
    nano /opt/php-7.0.9/lib/php.ini
    zend_extension=opcache.so
    memory_limit = 1024M
    post_max_size = 768M
    upload_max_filesize = 512M
    
    service httpd restart
    
    Path to the PHP FastCGI binary: /opt/php-7.0.9/bin/php-cgi
    Path to the php.ini directory: /opt/php-7.0.9/lib
    
    Path to the PHP-FPM init script: /etc/init.d/php-7.0.9-fpm
    Path to the php.ini directory: /opt/php-7.0.9/lib
    Path to the PHP-FPM pool directory: /opt/php-7.0.9/etc/php-fpm.d
    
    Now I get a 503 error when trying to use it.
    Can anyone help please?
     
    Last edited: Aug 24, 2016
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Does the compiled php binaries work?
    Which exact error do you get in the error.log of the website where this error occurs?
     
  3. I wouldn't know how to test the binaries.

    Code:
    [Wed Aug 24 05:20:37.809997 2016] [proxy:error] [pid 17998] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9013 (*) failed
    [Wed Aug 24 05:20:37.810118 2016] [proxy_fcgi:error] [pid 17998] [client 162.158.92.141:44253] AH01079: failed to make connection to backend: 127.0.0.1, referer: https://casso.la/forums/
    [Wed Aug 24 05:22:02.317314 2016] [proxy:error] [pid 17999] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9013 (*) failed
    [Wed Aug 24 05:22:02.317399 2016] [proxy_fcgi:error] [pid 17999] [client 69.162.124.237:33534] AH01079: failed to make connection to backend: 127.0.0.1, referer: https://main.casso.la
    [Wed Aug 24 05:22:22.576334 2016] [proxy:error] [pid 18009] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9013 (*) failed
    [Wed Aug 24 05:22:22.576444 2016] [proxy_fcgi:error] [pid 18009] [client 69.162.124.237:44267] AH01079: failed to make connection to backend: 127.0.0.1, referer: https://main.casso.la
    
    An excerpt from error.log
     
  4. I tried:
    Code:
    nano /opt/php-7.0.9/etc/php-fpm.d/www.conf
    [...]
    listen = 127.0.0.1:9013
    [...]
    But it didn't work
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The error means that the php7 fpm is not running. Undo the config file change that you made, it will break the setup.

    Do you get an error when you run:

    /etc/init.d/php-7.0.9-fpm restart

    ?
     
  6. Thanks.
    I undid the change I made regarding the listening port.

    Here the output of your suggetion:
    Code:
    /etc/init.d/php-7.0.9-fpm restart
    Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?
    Starting php-fpm [24-Aug-2016 06:39:42] ERROR: [pool www] cannot get uid for user 'www-data'
    [24-Aug-2016 06:39:42] ERROR: FPM initialization failed
    failed
    
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The compile options are for Debian, that's why a wrong user for apache is used. Try this to create a user and group www-data:

    adduser --system --home=/var/www --group www-data

    and then try again:

    /etc/init.d/php-7.0.9-fpm restart
     
  8. Thanks!
    I get this though:
    adduser: group 'www-data' does not exist

    Also: could I get the right configuration for centos 7 for future installations?
    You are also welcome to use any of the above in a php 7 centos 7 tutorial. :)
     
  9. Sorry but it doesn't work. I consider this method as not usable.

    I will try using the remi repo for installing php70.
     
  10. This setup is much easier and just worked:
    Code:
    wget https://centos7.iuscommunity.org/ius-release.rpm
    wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    rpm -Uvh ius-release.rpm
    rpm -Uvh remi-release-7*.rpm
    
    yum install php70-php-bcmath php70-php-cli php70-php-common php70-php-fpm php70-php-gd php70-php-intl php70-php-json php70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-opcache php70-php-pdo php70-php-pear php70-php-pecl-uploadprogress php70-php-pecl-zip php70-php-soap php70-php-xml php70-php-xmlrpc
    
    nano /etc/opt/remi/php70/php-fpm.d/www.conf
    […]
    listen = 127.0.0.1:9007
    […]
    
    systemctl start php70-php-fpm
    systemctl enable php70-php-fpm
    
    nano /etc/opt/remi/php70/php.ini
    […]
    memory_limit = 256M
    max_execution_time = 300
    upload_max_filesize = 256M
    post_max_size = 256M
    […]
    
    In ISPconfig adding the new PHP version (system):
    Path to the PHP FCGI binary: /opt/remi/php70/root/usr/bin/php-cgi
    Path to the php.ini directory: /etc/opt/remi/php70
    
    Path to the PHP-FPM init script: php70-php-fpm
    Path to the php.ini directory: /etc/opt/remi/php70
    Path to the PHP-FPM pool directory: /etc/opt/remi/php70/php-fpm.d
    
    service php70-php-fpm restart
    service httpd restart
    
     

Share This Page