Install PowerDNS and Poweradmin on a CentOS 7 VPS

Leave reply

install-powerdns-and-on-a-centos-7-vpsIn this tutorial, we will show you how to install PowerDNS and Poweradmin on a CentOS 7 VPS with Nginx, MariaDB and PHP-FPM. PowerDNS is a high-performance and reliable DNS server, written in C++ and can be used as an alternative to BIND. This guide should work on other Linux VPS systems as well but was tested and written for CentOS 7 VPS.

 

Install EPEL repository

rpm -Uhv http://mirror.cc.columbia.edu/pub/linux/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
root@vps:~# yum -y update

Install MariaDB

To install MariaDB server run the following command:

root@vps:~# yum install mariadb-server mariadb

To start the service and enable it at the boot time run:

root@vps:~# systemctl start mariadb.service
root@vps:~# systemctl enable mariadb.service

It is very important to secure your MariaDB server, run the following script before creating and populating the databases.

mysql_secure_installation

Once you are finished with the step above, login as a MariaDB root and create a new database and tables:

root@vps:~# mysql -uroot -p
create database powerdns;
GRANT ALL PRIVILEGES ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'powerdnsPassword';
use powerdns;

CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);

CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);

CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
exit;

Install PDNS

To install the latest version of powerdns just run:

root@vps:~# yum install pdns-backend-mysql pdns

Open the `/etc/pdns/pdns.conf` file and add the following lines:

launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=powerdnsPassword
gmysql-dbname=powerdns

and restart the Power DNS service:

systemctl restart pdns.service
systemctl enable pdns.service

Install and configure PHP and Nginx

Installing PHP and Nginx is pretty easy, just run the following command:

root@vps:~# yum install nginx php-fpm php-cli php-mysqlnd php-mcrypt

To change PHP-FPM to listen on a unix socket, open the default www pool

root@vps:~# vim /etc/php-fpm.d/www.conf

and change from:

listen = 127.0.0.1:9000

to:

listen = /var/run/php-fpm/php-fpm.socket

and restart the service for changes to take effect.

root@vps:~# systemctl restart php-fpm

Create a php session directory and change the ownership to apache (the user under which PHP runs).

root@vps:~# mkdir /var/lib/php/session
root@vps:~# chown apache:apache /var/lib/php/session

Create a new Nginx server block with the following content:

root@vps:~# cat <<'EOF' >> /etc/nginx/conf.d/pdns.your-domain.com.conf
server {
server_name pdns.your-domain.com;
listen 80;
root /var/www/html/pdns.your-domain.com;
access_log /var/log/nginx/pdns.your-domain.com-access.log;
error_log /var/log/nginx/pdns.your-domain.com-error.log;
index index.php;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_keep_conn on;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\.ht {
deny all;
}

}
EOF

Test the Nginx configuration and restart the server by running the following commands:

root@vps:~# nginx -t
root@vps:~# systemctl restart nginx

Install Poweradmin

To download and extract the latest version of Poweradmin, run the followind commands:

root@vps:~# mkdir -p /var/www/html/pdns.your-domain.com/
root@vps:~# cd /var/www/html/pdns.your-domain.com/
root@vps:~# wget http://downloads.sourceforge.net/project/poweradmin/poweradmin-2.1.7.tgz
root@vps:~# tar -xvzf poweradmin-2.1.7.tgz
root@vps:~# mv poweradmin-2.1.7/* .
root@vps:~# rm -rf poweradmin-2.1.7*

Set the correct permissions:

root@vps:~# chown -R apache:apache /var/www/html/pdns.your-domain.com/

To start the installation wizard, open your browser and type http://pdns.your-domain.com/installer

Step 1: Select the desired language,
Step 2: Just click on the “Go to step 3” button
Step 3: Fill the database information fields, select “MySQL” for Database type and “localhost” for the “Hostname” and set the Poweradmin administrator password.
Step 4: Set the username and password for Poweradmin, Hostmaster and Primary and Secondary nameservers.
Step 5: Before going to next step to create less privileged user poweradmin, perform the mariadb command shown on the screen.
Step 6: If you have set the correct permissions the installer will create your poweradmin php configuration file.

After the installation wizard completes, remove the install directory using the following command:

root@vps:~# rm -rf install/

That’s it, you have successfully installed PowerDNS and Poweradmin on your VPS!


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to set this up for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.


50% OFF Coupon

EXCLUSIVE EMAIL UPDATES AND “MEMBERS-ONLY” CONTENT


12 Responses to “Install PowerDNS and Poweradmin on a CentOS 7 VPS”

  1. Links 7/12/2014: Typhoon Hagupit, AURORAGOLD | Techrights

    […] Install PowerDNS and Poweradmin on a CentOS 7 VPS […]

    Reply
  2. Paul Hermans

    I had to disable SELINUX to make poweradmin load.

    Reply
  3. dedy

    I was install powerdns and poweradmin, but if i dig @localhost or dig @ IPSERVER the query result are REFUSED, why?

    Reply
  4. sirmonkey

    something is wrong with your nginx config (or nginx ? )
    installed Apache and poweradmin worked fine. with nginx i kept getting 404 errors.
    there is a probably a problem in a recent Cent7 release, since 7.1 I’ve had regular problems :-/ but work wants centos

    Reply
    • admin

      You should check the error log for details. Also sure that you use the correct values for root and fastcgi_pass directives.

      Reply
  5. sirmonkey

    also powerdns also needed
    ALTER TABLE records ADD disabled TINYINT(1) DEFAULT 0 AFTER change

    Reply
  6. Christopher H

    If you are getting 403 errors, DO NOT CHANGE ANY FILE PERMISSIONS!

    Instead, run the following two commands:

    setsebool -P httpd_enable_homedirs true
    chcon -R -t httpd_sys_content_t /var/www/html/pdns.your-domain.com.conf/

    Reply
  7. Chris Paquin

    I am following these instructions, trying to install poweradmin on RHEL 7.

    I never get the installer screens for poweradmin, instead, I just see this error. This does not make sense. I thought the installer was supposed to generate the config.inc.php.

    Error: You have to create a config.inc.php!
    Poweradmin

    Error: The install/ directory exists, you must remove it first before proceeding.
    a complete(r) poweradmin – credits

    Reply
    • admin

      According to the error messages, you need to create a config.inc.php file and remove the install/ directory.

      cd /var/www/html/pdns.your-domain.com/
      touch inc/config.inc.php
      chown apache:apache inc/config.inc.php
      rm -rf install/

      Thanks

      Reply

Leave a Reply