FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

languages:php:index.html



Top#Programming Languages

PHP (php.py)

PHP Operation

Fabric one-line Task Examples

$ fab -l |grep -F php.

$ fab  -H $H   php.install_yum

Fabric one-line Task Examples

$ H=test-server-1,test-server-2

$ fab  -H $H   -- "php -v"


php.py

$FHHOME/fabfile/php.py

import sys
from fabric.api import *
from fabric.contrib import files

#----------------------------------------------------------------------
# Check PHP
#----------------------------------------------------------------------
# php.check_php_rpm
@task
def check_php_rpm():
    '''rpm -q php'''
    run("rpm -q php")
    run("php --version")



#----------------------------------------------------------------------
# Installing PHP
#----------------------------------------------------------------------
# php.install_yum
@task
def install_yum():
    sudo("rpm -q php            > /dev/null 2>&1 || yum -y install php")
    sudo("rpm -q php-mbstrig    > /dev/null 2>&1 || yum -y install php-mbstrig") 

# php.install_phpfpm_yum
@task
def install_phpfpm_yum():
    sudo("yum -y install php-cli php-mbstring php-fpm")


## CentOS7 ##
@task
def install_php5.6_centos7():
    sudo("rpm -q remi-release-7  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm")
    sudo("yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")

@task
def install_php7.0_centos7():
    sudo("rpm -q remi-release-7  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm")
    sudo("yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")

@task
def install_php7.1_centos7():
    sudo("rpm -q remi-release-7  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm")
    sudo("yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")
    run("rpm -q php")
    run("php --version")


## CentOS6 ##
@task
def install_php5.6_centos6():
    sudo("rpm -q remi-release-6  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm")
    sudo("yum install --enablerepo=remi,remi-php56 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")

@task
def install_php7.0_centos6():
    sudo("rpm -q remi-release-6  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm")
    sudo("yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")

@task
def install_php7.1_centos6():
    sudo("rpm -q remi-release-6  > /dev/null 2>&1 || rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm")
    sudo("yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt")
    run("rpm -q php")
    run("php --version")


#----------------------------------------------------------------------
# Installing composer
#----------------------------------------------------------------------
@task
def install_composer():
    sudo("curl -sS https://getcomposer.org/installer | php")
    sudo("mv composer.phar /usr/local/bin/composer")



PHP Configuration



languages/php/index.html.txt ยท Last modified: 2019/02/11 00:48 by kurihara