henrydenhengst

Install PowerDNS and PowerAdmin on an Ubuntu 14.04 LTS

Dec 4th, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.51 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Check root privileges
  4. if [[ $EUID -ne 0 ]]; then
  5.    echo "This script must be run as root"
  6.    exit 1
  7. fi
  8. #
  9. apt-get update && sudo apt-get -y upgrade
  10. apt-get install software-properties-common vim git
  11. #
  12. # Install MariaDB 10.0
  13. apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
  14. add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu trusty main'
  15. apt-get update
  16. apt-get install -y mariadb-server
  17. # secure your installation
  18. mysql_secure_installation
  19. # Install PowerDNS
  20. apt-get install pdns-server pdns-backend-mysql
  21. # Select Yes to create and configure database for pdns-backend-mysql with dbconfig-common.
  22. # Provide the password of the database’s administrative user (MySQL root user password)
  23. # and choose a password for the pdns-backend-mysql user.
  24. # The database information will be written to the pdns.local.gmysql.conf file.
  25. #
  26. # Clone Poweradmin
  27. git clone https://github.com/poweradmin/poweradmin.git /var/www/html/pdns.myDomain.com/
  28. # Set the correct permissions
  29. chown -R www-data: /var/www/html/pdns.myDomain.com/
  30. # Install and configure PHP and required PHP modules
  31. add-apt-repository -y ppa:ondrej/php5-5.6
  32. sudo apt-get update
  33. sudo apt-get -y install php5-fpm php5-cli php5-gd php5-mysqlnd php5-mcrypt
  34. # Edit the PHP-FPM pool configuration file
  35. mv /etc/php5/fpm/pool.d/www.conf{,.bak}
  36. #
  37. cat >/etc/php5/fpm/pool.d/www.conf <<-EOF
  38. [www]
  39. user = www-data
  40. group = www-data
  41. listen = /var/run/php5-fpm.sock
  42. listen.owner = www-data
  43. listen.group = www-data
  44. listen.mode = 0666
  45. pm = ondemand
  46. pm.max_children = 5
  47. pm.process_idle_timeout = 10s;
  48. pm.max_requests = 200
  49. chdir = /
  50. EOF
  51. #
  52. # Restart PHP-FPM
  53. service php5-fpm restart
  54. #
  55. # Install and configure Nginx
  56. #
  57. # Ubuntu 14.04 comes with nginx version 1.4, to install the latest stable version of Nginx version 1.8
  58. add-apt-repository -y ppa:nginx/stable
  59. apt-get update
  60. apt-get -y install nginx
  61. # Create a new Nginx server block with the following content
  62. #
  63. cat >/etc/nginx/sites-available/pdns.myDomain.com <<-EOF
  64. server {
  65.     server_name pdns.myDomain.com;
  66.     listen 80;
  67.     root /var/www/html/pdns.myDomain.com;
  68.  
  69.     access_log /var/log/nginx/pdns-access.log;
  70.     error_log /var/log/nginx/pdns-error.log;
  71.  
  72.     index index.php;
  73.  
  74.     location / {
  75.         try_files $uri $uri/ /index.php?$query_string;
  76.     }
  77.  
  78.     location ~ \.php$ {
  79.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  80.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  81.         fastcgi_index index.php;
  82.         include fastcgi_params;
  83.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  84.         fastcgi_intercept_errors off;
  85.         fastcgi_buffer_size 16k;
  86.         fastcgi_buffers 4 16k;
  87.     }
  88.  
  89.     location ~ /\.ht {
  90.         deny all;
  91.     }    
  92. }
  93. EOF
  94. #
  95. # Activate the server block by creating a symbolic link
  96. ln -s /etc/nginx/sites-available/pdns.myDomain.com /etc/nginx/sites-enabled/pdns.myDomain.com
  97. # Test the Nginx configuration and restart nginx
  98. nginx -t
  99. service nginx restart
  100. #
  101. clear
  102. echo "Install Poweradmin"
  103. echo " "
  104. echo "To start the installation wizard, open your browser and type http://pdns.myDomain.com/installer"
  105. echo " Step 1: Select the desired language,"
  106. echo " Step 2: Click on the “Go to step 3” button"
  107. echo " Step 3: Fill the database information fields:"
  108. echo "   – Username: pdns"
  109. echo "   – Password: yourPdnsUserPassword"
  110. echo "   – Database type: MySQL"
  111. echo "   – Hostname: localhost"
  112. echo "   – DB Port: 3306"
  113. echo "   – Database: pdns"
  114. echo "   – Poweradmin administrator password: setYourPoweradminAdminPassword"
  115. echo " Step 4: Set the username and password for Poweradmin, Hostmaster and Primary and Secondary nameservers."
  116. echo " Step 5: Before going to next step, perform the mariadb command shown on the screen..."
  117. #
  118. mysql -uroot -p<password> -e"GRANT SELECT, INSERT, UPDATE, DELETE ON pdns.* TO 'yourUser'@'localhost' IDENTIFIED BY 'yourUserPassword'"
  119. # or
  120. mysql -uroot -p << EOF
  121. GRANT SELECT, INSERT, UPDATE, DELETE
  122. ON example.*
  123. TO 'yourUser'@'localhost'
  124. IDENTIFIED BY 'yourUserPassword';
  125. EOF
  126. #
  127. echo " Step 6: If you have set the correct permissions the installer will"
  128. echo " Step 7: create a Poweradmin php configuration file."
  129. # After the installation wizard completes,
  130. # remove the install directory using the following command:
  131. rm -rf install/
  132. # You have successfully installed PowerDNS and Poweradmin
  133. # You can now login to the Poweradmin interface using
  134. # admin as username and setYourPoweradminAdminPassword as password.
Advertisement
Add Comment
Please, Sign In to add comment