KOINS.Studio - Articles - Инсталляция и настройка программ - php - Upgrade php 5.5 to php 7.0 (on Amazon Linux)

Upgrade php 5.5 to php 7.0 (on Amazon Linux)

  • Download and install repository:
    wget http://mirrors.mediatemple.net/remi/enterprise/remi-release-6.rpm
    yum install remi-release-6.rpm

  • Uninstall old versions:
    pecl uninstall ssh2
    pecl uninstall rar
    yum remove php mod_php php-cli php-xml php-common

  • Remove /etc/php.d directory.

  • Upgrade software:
    yum update

  • Install dependency libraries:
    yum install libssh2 libssh2-devel memcached libevent libevent-devel gcc

  • Edit
    /etc/yum.repos.d/epel.repo
    and set
    enabled=1

  • Install packages:
    yum install php70 php70-php-fpm php70-php-mysqlnd php70-php-cli php70-php-apcu php70-php-bcmath php70-php-gd php70-php-mcrypt php70-php-mbstring php70-php-tidy php70-php-domxml php70-php-soap php70-php-process php70-php-opcache php70-php-json php70-php-devel php70-php-pear php70-php-pecl-zip

  • Temporarily disable Amazon repository:
    /etc/yum.repos.d/amzn-main.repo
    [amzn-main]
    enabled=0
    Install memcached:
    yum install php70-php-pecl-memcached
    Enable repository back.

  • /etc/opt/remi/php70/php.ini
    memory_limit=1024M
    display_errors=off
    error_reporting=E_ALL
    allow_url_fopen=on
    display_startup_errors=off
    log_errors=on
    html_errors=off
    max_input_time=600
    post_max_size=10M
    upload_max_filesize=10M

  • Move
    /etc/opt/remi/php70/php-fpm.d/www.conf
    to
    /etc/opt/remi/php70/php-fpm.default.conf
    Edit it:
    Remove definition of pool name.
    Comment out the following lines:
    ;listen = 127.0.0.1:9000
    ;php_admin_value[error_log] = /var/opt/remi/php70/log/php-fpm/www-error.log
    ;php_admin_flag[log_errors] = on

    Uncomment and add .html extension to the following setting:
    security.limit_extensions

  • Create settings for each domain:
    /etc/opt/remi/php70/php-fpm.d/demo.conf
    [demo]

    include=/etc/opt/remi/php70/php-fpm.default.conf

    listen = 127.0.0.1:9000

    php_admin_value[error_log] = /home/rs/.htprivate/rs/writable/log/php.log
  • Run PHP-FPM:
    chkconfig php70-php-fpm on
    /etc/init.d/php70-php-fpm start

  • Switch Apache from prefork to mpm event worker (this is required because mod_php isn't thread safe) in /etc/httpd/conf.modules.d/00-mpm.conf:
    LoadModule mpm_event_module modules/mod_mpm_event.so
    Comment out loading of mpm_prefork_module.

  • Instruct apache to pass all php requests to php-fpm.
    Add to your /etc/httpd/vhosts.d/*.conf:
      <FilesMatch \.(php|html)$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
      </FilesMatch>
  • /home/rs/.htprivate/htconfig/root.conf
    Comment out all php_* commands.
    Process for all domains.

  • Add .htaccess to configuration directory into core/mp/html/.htaccess.
    Remove all PHP settings from this file.

  • Restart Apache:
    /etc/init.d/httpd restart

  • Create symlinks:
    /opt/remi/php70/root/usr/bin/pecl -> /usr/bin/pecl
    /opt/remi/php70/root/usr/bin/php -> /usr/bin/php
    /opt/remi/php70/root/usr/bin/php-config -> /usr/bin/php-config
    /opt/remi/php70/root/usr/bin/phpize -> /usr/bin/phpize

  • Install SSH2 extension:
    wget https://github.com/Sean-Der/pecl-networking-ssh2/archive/php7.zip
    unzip php7
    cd pecl-networking-ssh2-php7
    phpize
    ./configure
    make
    make install

  • Create file
    /etc/opt/remi/php70/php.d/30-ssh2.ini

  • /home/control/public_html/apc.php
    APC extension is renamed to APCu. Also, argument of apcu_clear_cache() is removed:
    <?php
    if(function_exists('apcu_clear_cache'))
    {
      
    apcu_clear_cache();
    }
    ?>

Set up FPM status page

  • Generate page name. Add it to
    /etc/opt/remi/php70/php-fpm.default.conf
    pm.status_path=/Wj0ulGMO30BR

  • Create password file:
    htdigest -c koins.pwd Restricted zone koins

  • Add instruction to your apache configuration:
      <LocationMatch "/Wj0ulGMO30BR">
        AuthType Digest
        AuthName "Restricted zone"
        AuthDigestProvider file
        AuthUserFile "/etc/httpd/vhosts.d/koins.pwd"
        <RequireAll>
          Require ip 1.2.3.4 5.6.7.8
          Require valid-user
        </RequireAll>

        ProxyPass fcgi://127.0.0.1:9000/Wj0ulGMO30BR
      </LocationMatch>
  • Save path, login and password to passwords.

See also

Last modification: 13.04.16 13:46