Advertisement
Guest User

ppnuca

a guest
Jan 12th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. #!/bin/bash
  2. set -ex
  3. yum update -y
  4. yum install -y haproxy
  5. #!/bin/bash
  6. set -ex
  7. echo "global
  8. log 127.0.0.1 local0
  9. log 127.0.0.1 local1 notice
  10. maxconn 4096
  11. quiet
  12. user haproxy
  13. group haproxy
  14. defaults
  15. log global
  16. mode http
  17. retries 3
  18. timeout client 50s
  19. timeout connect 5s
  20. timeout server 50s
  21. option dontlognull
  22. option httplog
  23. option redispatch
  24. balance roundrobin
  25. # Set up application listeners here.
  26. listen admin
  27. bind 127.0.0.1:22002
  28. mode http
  29. stats uri /
  30. frontend http
  31. maxconn 2000
  32. bind 0.0.0.0:80
  33. default_backend servers-http
  34. backend servers-http" | tee /etc/haproxy/haproxy.cfg
  35. hosts=$(echo "@@{App01Service.address}@@,@@{App02Service.address}@@" | tr "," "\n")
  36. port=80
  37. for host in $hosts
  38. do echo " server host-${host} ${host}:${port} weight 1 maxconn 100 check" | tee -a /etc/haproxy/haproxy.cfg
  39. done
  40. systemctl daemon-reload
  41. systemctl restart haproxy
  42. firewall-cmd --add-service=http --zone=public --permanent
  43. firewall-cmd --reload
  44.  
  45.  
  46. Load Balancer Uninstall Script
  47. yum -y erase haproxy
  48.  
  49.  
  50. Web-Application Install Script
  51.  
  52.  
  53. #!/bin/bash
  54. yum update -y
  55. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  56.  
  57. yum install -y nginx php56w-fpm php56w-cli php56w-mcrypt php56w-mysql php56w-mbstring php56w-dom git
  58. mkdir -p /var/www/laravel
  59. echo "server {
  60. listen 80 default_server;
  61. listen [::]:80 default_server ipv6only=on;
  62. root /var/www/laravel/public/;
  63. index index.php index.html index.htm;
  64. location / {
  65. try_files \$uri \$uri/ /index.php?\$query_string;
  66. }
  67. # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
  68. location ~ \.php$ {
  69. try_files \$uri /index.php =404;
  70. fastcgi_split_path_info ^(.+\.php)(/.+)\$;
  71. fastcgi_pass 127.0.0.1:9000;
  72. fastcgi_index index.php;
  73. fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  74. include fastcgi_params;
  75. }
  76. }" | tee /etc/nginx/conf.d/laravel.conf
  77. sed -i 's/80 default_server/80/g' /etc/nginx/nginx.conf
  78. if `grep "cgi.fix_pathinfo" /etc/php.ini` ; then
  79. sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
  80. else
  81. sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
  82. fi
  83. #sudo php5enmod mcrypt
  84. systemctl restart php-fpm
  85. systemctl restart nginx
  86. if [ ! -e /usr/local/bin/composer ]
  87. then
  88. curl -sS https://getcomposer.org/installer | php
  89. mv composer.phar /usr/local/bin/composer
  90. chmod +x /usr/local/bin/composer
  91. fi
  92. git clone https://github.com/ideadevice/quickstart-basic.git /var/www/laravel
  93. sed -i 's/DB_HOST=.*/DB_HOST=@@{DBService.address}@@/' /var/www/laravel/.env
  94. #if [ "@@{calm_array_index}@@" == "0" ]; then
  95. sudo su - -c "cd /var/www/laravel; composer install ; php artisan migrate"
  96. #fi
  97. chown -R nginx:nginx /var/www/laravel
  98. chmod -R 777 /var/www/laravel/
  99. systemctl restart nginx
  100. firewall-cmd --add-service=http --zone=public --permanent
  101. firewall-cmd --reload
  102.  
  103.  
  104. Web-Application Uninstall Script
  105.  
  106.  
  107. rf /var/www/laravel
  108. yum erase -y nginx
  109.  
  110.  
  111. Database Install Script
  112. #!/bin/bash
  113. set -ex
  114. yum update -y
  115. platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | cut -d. -f1`
  116. if [ $platform_version -eq 7 ];then
  117. if [ "@@{DBService.MYSQL_VERSION}@@" == "5.5" ];then
  118. mysql_repo_package="http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm"
  119. elif [ "@@{DBService.MYSQL_VERSION}@@" == "5.6" ];then
  120. mysql_repo_package="http://repo.mysql.com/mysql-community-release-el7.rpm"
  121. elif [ "@@{DBService.MYSQL_VERSION}@@" == "5.7" ];then
  122. mysql_repo_package="https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm"
  123. fi
  124. else
  125. echo "Version Not supported"
  126. fi
  127. yum install -y $mysql_repo_package
  128. yum update -y
  129. yum install -y mysql-community-server.x86_64
  130. /bin/systemctl start mysqld
  131. #Mysql secure installation
  132. mysql -u root<<-EOF
  133. UPDATE mysql.user SET Password=PASSWORD('@@{DBService.MYSQL_PASSWORD}@@') WHERE User='root';
  134. DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
  135. DELETE FROM mysql.user WHERE User='';
  136. DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
  137. FLUSH PRIVILEGES;
  138. EOF
  139. firewall-cmd --add-service=mysql --permanent
  140. firewall-cmd --reload
  141. mysql -u root -p"@@{DBService.MYSQL_PASSWORD}@@"<<-EOF
  142. CREATE DATABASE homestead;
  143. GRANT ALL PRIVILEGES ON homestead.* TO 'homestead'@'%' identified by 'secret';
  144. FLUSH PRIVILEGES;
  145. EOF
  146.  
  147.  
  148. Database Uninstall Script
  149. set -ex
  150. yum remove -y mysql-community-server.x86_64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement