SHARE
TWEET

Untitled

a guest Feb 12th, 2019 68 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 = "dummywordpressblog124.com"
  5. $config = "server {
  6.     listen 80;
  7.     root $web_dir/$site_name;
  8.     index index.html index.htm index.php;
  9.     server_name _;
  10.     location ~ \.php$ {
  11.         include snippets/fastcgi-php.conf; 
  12.         fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  13.     }
  14. }
  15. "
  16.  
  17. #list of packages for installation
  18. $base_packages = [
  19.     "mysql-server",
  20.     "nginx",
  21.     "php7.0-fpm",
  22. ]
  23.  
  24. #install packages
  25. package{$base_packages:
  26.     ensure => installed,   
  27. }
  28.  
  29.  
  30. #create dir for web site
  31. file { ["$web_dir",
  32.     "$web_dir/$site_name"]:
  33.     ensure => 'directory',
  34. #   recurse => true,
  35. #   owner  => 'root',
  36. #   group  => 'wheel',
  37. #   mode   => '0750',
  38.   }
  39.  
  40. #create index.php file in site dir
  41. file { "$web_dir/$site_name/index.php":
  42.     ensure => 'present',
  43.     content => [
  44.         "<?php phpinfo(); ?>",
  45.     ],
  46. }
  47.  
  48. #delete default config for nginx
  49. file { "$nginx_sites_enabled/default":
  50.     ensure => 'absent',
  51. }
  52.  
  53. #create config file for nginx from template
  54. file { "$nginx_sites_available/$site_name":
  55.     ensure => 'present',
  56.     content => $config
  57. }
  58.  
  59. #create symbolic link for enabling config file
  60. file { "$nginx_sites_enabled/$site_name":
  61.     ensure => 'link',
  62.     target => "$nginx_sites_available/$site_name"
  63. }
  64.  
  65. #testing nginx config and reload web-server
  66. exec { "nginx -s reload":
  67.         path   => "/usr/bin:/usr/sbin:/bin",
  68.     onlyif => "nginx -t",
  69. }
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