Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -ex
- yum update -y
- yum install -y haproxy
- #!/bin/bash
- set -ex
- echo "global
- log 127.0.0.1 local0
- log 127.0.0.1 local1 notice
- maxconn 4096
- quiet
- user haproxy
- group haproxy
- defaults
- log global
- mode http
- retries 3
- timeout client 50s
- timeout connect 5s
- timeout server 50s
- option dontlognull
- option httplog
- option redispatch
- balance roundrobin
- # Set up application listeners here.
- listen admin
- bind 127.0.0.1:22002
- mode http
- stats uri /
- frontend http
- maxconn 2000
- bind 0.0.0.0:80
- default_backend servers-http
- backend servers-http" | tee /etc/haproxy/haproxy.cfg
- hosts=$(echo "@@{App01Service.address}@@,@@{App02Service.address}@@" | tr "," "\n")
- port=80
- for host in $hosts
- do echo " server host-${host} ${host}:${port} weight 1 maxconn 100 check" | tee -a /etc/haproxy/haproxy.cfg
- done
- systemctl daemon-reload
- systemctl restart haproxy
- firewall-cmd --add-service=http --zone=public --permanent
- firewall-cmd --reload
- Load Balancer Uninstall Script
- yum -y erase haproxy
- Web-Application Install Script
- #!/bin/bash
- yum update -y
- rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- yum install -y nginx php56w-fpm php56w-cli php56w-mcrypt php56w-mysql php56w-mbstring php56w-dom git
- mkdir -p /var/www/laravel
- echo "server {
- listen 80 default_server;
- listen [::]:80 default_server ipv6only=on;
- root /var/www/laravel/public/;
- index index.php index.html index.htm;
- location / {
- try_files \$uri \$uri/ /index.php?\$query_string;
- }
- # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
- location ~ \.php$ {
- try_files \$uri /index.php =404;
- fastcgi_split_path_info ^(.+\.php)(/.+)\$;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
- include fastcgi_params;
- }
- }" | tee /etc/nginx/conf.d/laravel.conf
- sed -i 's/80 default_server/80/g' /etc/nginx/nginx.conf
- if `grep "cgi.fix_pathinfo" /etc/php.ini` ; then
- sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
- else
- sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
- fi
- #sudo php5enmod mcrypt
- systemctl restart php-fpm
- systemctl restart nginx
- if [ ! -e /usr/local/bin/composer ]
- then
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- chmod +x /usr/local/bin/composer
- fi
- git clone https://github.com/ideadevice/quickstart-basic.git /var/www/laravel
- sed -i 's/DB_HOST=.*/DB_HOST=@@{DBService.address}@@/' /var/www/laravel/.env
- #if [ "@@{calm_array_index}@@" == "0" ]; then
- sudo su - -c "cd /var/www/laravel; composer install ; php artisan migrate"
- #fi
- chown -R nginx:nginx /var/www/laravel
- chmod -R 777 /var/www/laravel/
- systemctl restart nginx
- firewall-cmd --add-service=http --zone=public --permanent
- firewall-cmd --reload
- Web-Application Uninstall Script
- rf /var/www/laravel
- yum erase -y nginx
- Database Install Script
- #!/bin/bash
- set -ex
- yum update -y
- platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | cut -d. -f1`
- if [ $platform_version -eq 7 ];then
- if [ "@@{DBService.MYSQL_VERSION}@@" == "5.5" ];then
- mysql_repo_package="http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm"
- elif [ "@@{DBService.MYSQL_VERSION}@@" == "5.6" ];then
- mysql_repo_package="http://repo.mysql.com/mysql-community-release-el7.rpm"
- elif [ "@@{DBService.MYSQL_VERSION}@@" == "5.7" ];then
- mysql_repo_package="https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm"
- fi
- else
- echo "Version Not supported"
- fi
- yum install -y $mysql_repo_package
- yum update -y
- yum install -y mysql-community-server.x86_64
- /bin/systemctl start mysqld
- #Mysql secure installation
- mysql -u root<<-EOF
- UPDATE mysql.user SET Password=PASSWORD('@@{DBService.MYSQL_PASSWORD}@@') WHERE User='root';
- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
- DELETE FROM mysql.user WHERE User='';
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
- FLUSH PRIVILEGES;
- EOF
- firewall-cmd --add-service=mysql --permanent
- firewall-cmd --reload
- mysql -u root -p"@@{DBService.MYSQL_PASSWORD}@@"<<-EOF
- CREATE DATABASE homestead;
- GRANT ALL PRIVILEGES ON homestead.* TO 'homestead'@'%' identified by 'secret';
- FLUSH PRIVILEGES;
- EOF
- Database Uninstall Script
- set -ex
- yum remove -y mysql-community-server.x86_64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement