SHARE
TWEET

Untitled

a guest Mar 1st, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $web_dir = "/tmp/web"
  2. $nginx_sites_available = "/etc/nginx/sites-available"
  3. $nginx_sites_enabled = "/etc/nginx/sites-enabled"
  4. $site_name = "phpmyadmin.local"
  5. $phpMyAdminURL = "https://files.phpmyadmin.net/phpMyAdmin/4.8.5/phpMyAdmin-4.8.5-all-languages.zip"
  6. $config = "server {
  7.     listen 80;
  8.     root $web_dir/$site_name;
  9.     index index.html index.htm index.php;
  10.     server_name _;
  11.     location ~ \.php$ {
  12.         include snippets/fastcgi-php.conf; 
  13.         fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  14.     }
  15. }
  16. "
  17. #Removing packages that interfere with the installation of MySQL
  18. package{"mariadb-libs":
  19.     ensure => removed,
  20. }
  21.  
  22. #Install dependencies for Nginx
  23. package{"epel-release":
  24.     ensure => installed,
  25. }
  26.  
  27.  
  28. # Add Nginx repo
  29. yumrepo { 'nginx_stable_repo':
  30.     enabled  => 1,
  31.     descr    => 'nginx_stable_repo',
  32.     baseurl  => 'http://nginx.org/packages/centos/$releasever/$basearch/',
  33.     gpgcheck => 1,
  34.     gpgkey   => 'https://nginx.org/keys/nginx_signing.key',
  35. }
  36.  
  37. # Add php repo
  38. package { 'php':
  39.     provider         => 'rpm',
  40.     ensure      => installed,
  41.     source => 'https://mirror.webtatic.com/yum/el7/webtatic-release.rpm',
  42. }
  43.  
  44. exec {'yum -y update':}
  45.  
  46. #list of packages for installation
  47. $base_packages = [
  48.     "nginx",
  49.     "php70w-fpm",
  50.     "php70w-bcmath",
  51.     "php70w-pecl-imagick",
  52.     "php70w-pdo",
  53.     "perl-Data-Dumper",
  54.     "redis",
  55. ]
  56.  
  57. #install packages
  58. package{$base_packages:
  59.     ensure => installed,
  60. }
  61.  
  62. package { 'mysql-server':
  63.     provider         => 'rpm',
  64.     ensure      => installed,
  65.     source => 'https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.43-1.el7.x86_64.rpm',
  66. }
  67.  
  68. #create dir for web site
  69. file { ["$web_dir",
  70.     "$web_dir/$site_name"]:
  71.     ensure => 'directory',
  72.   }
  73.  
  74.  
  75. archive { "phpMyAdmin":
  76.   source       => $phpMyAdminURL,
  77.   extract      => true,
  78.   extract_path => $web_dir/$site_name,
  79.   cleanup      => true,
  80.   path         => "/tmp/phpMyAdmin-4.8.5-all-languages.zip"
  81. }
  82.  
  83. #delete default config for nginx
  84. file { "$nginx_sites_enabled/default":
  85.     ensure => 'absent',
  86. }
  87.  
  88. #create config file for nginx from template
  89. file { "$nginx_sites_available/$site_name":
  90.     ensure => 'present',
  91.     content => $config
  92. }
  93.  
  94. #create symbolic link for enabling config file
  95. file { "$nginx_sites_enabled/$site_name":
  96.     ensure => 'link',
  97.     target => "$nginx_sites_available/$site_name"
  98. }
  99.  
  100. #testing nginx config and reload web-server
  101. exec { "nginx -s reload":
  102.         path   => "/usr/bin:/usr/sbin:/bin",
  103.     onlyif => "nginx -t",
  104. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top