{"id":4939,"date":"2018-06-19T15:40:08","date_gmt":"2018-06-19T11:40:08","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/ubuntu-postgresql-installation\/"},"modified":"2018-06-19T15:40:08","modified_gmt":"2018-06-19T11:40:08","slug":"how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04\/","title":{"rendered":"How to Install PostgreSQL and phpPgAdmin on Ubuntu 18.04"},"content":{"rendered":"<p>PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features.<\/p>\n<p>PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows. PhpPgAdmin is a PHP-based web application for managing PostgreSQL databases. With Phppgadmin, it is easy to create a database, create a role and create tables in Postgres.<\/p>\n<p>This tutorial will show the installation of PostgreSQL and its web-based administration interface phpPgAdmin on Ubuntu 18.04 LTS (Bionic Beaver). I will use the\u00a0<a href=\"https:\/\/www.howtoforge.com\/tutorial\/ubuntu-lts-minimal-server\/\" target=\"_blank\" rel=\"noopener\">Ubuntu minimal server<\/a> as a basis for this setup.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>Ubuntu 18.04<\/li>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>Install PostgreSQL and phpPgAdmin<\/li>\n<li>Configure Postgres User<\/li>\n<li>Configure Apache2<\/li>\n<li>Configure phpPgAdmin<\/li>\n<li>Testing<\/li>\n<\/ol>\n<h2 id=\"step-install-postgresql-phppgadmin-and-all-dependencies\">Step 1 &#8211; Install PostgreSQL, phpPgAdmin and All Dependencies<\/h2>\n<p>Before installing any packages on the Ubuntu system, update all available repositories.<\/p>\n<p class=\"command\">sudo apt update<\/p>\n<p>And now we&#8217;re ready for installing PostgreSQL, phpPgAdmin, and Apache2 packages.<\/p>\n<p>PostgreSQL and PhpPgAdmin are available in the Ubuntu repository. So you just need to install them with the apt command.<\/p>\n<p class=\"command\">sudo apt -y install postgresql postgresql-contrib phppgadmin<\/p>\n<p>The above command will automatically install all packages needed by PostgreSQL and phpPgAdmin, like Apache2, PHP etc.<\/p>\n<h2 id=\"step-configure-postgres-user\">Step 2 &#8211; Configure Postgres User<\/h2>\n<p>PostgreSQL uses role for user authentication and authorization, it just like Unix-Style permissions. By default, PostgreSQL creates a new user called &#8220;postgres&#8221; for basic authentication. To use PostgreSQL, you need to login to the &#8220;postgres&#8221; account, you can do that by typing:<\/p>\n<p class=\"command\">su &#8211; postgres<\/p>\n<p>Now you can access the PostgreSQL prompt with the command:<\/p>\n<p class=\"command\">psql<\/p>\n<p>And then change the password for postgres role by typing:<\/p>\n<p class=\"command\">\\password postgres<br \/>TYPE THE POSTGRES PASSWORD<\/p>\n<p>Then enter \\q to leave the psql command line.<\/p>\n<p class=\"command\">\\q<\/p>\n<p>Run the command &#8220;exit&#8221; to leave the postgres user and become root again.<\/p>\n<p class=\"command\">exit<\/p>\n<p><a class=\"fancybox\" id=\"img-11\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/11.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04.png\" alt=\"Set a PostgreSQL password\" width=\"500\" height=\"288\" title=\"\"><\/a><\/p>\n<h2 id=\"step-configure-apache-web-server\">Step 3 &#8211; Configure Apache Web Server<\/h2>\n<p>You need to configure Apache virtual host configuration for phpPgAdmin.<\/p>\n<p>Goto the &#8216;\/etc\/apache2\/conf-available&#8217; directory and edit the configuration file &#8216;phppgadmin.conf&#8217; with\u00a0<a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener\">vim<\/a> by typing:<\/p>\n<p class=\"command\">cd \/etc\/apache2\/conf-available\/<br \/>vim phppgadmin.conf<\/p>\n<p>Comment out the line &#8216;#Require local&#8217; by adding a # in front of the line and add below the line allow from all so that you can access from your browser.<\/p>\n<pre>Require all granted<\/pre>\n<p>Save and exit.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-1.png\" alt=\"Configure Apache Web server\" width=\"384\" height=\"87\" title=\"\"><\/a><\/p>\n<h2 id=\"step-configure-phppgadmin\">Step 4 &#8211; Configure phpPgAdmin<\/h2>\n<p>Go to the &#8216;\/etc\/phppgadmin&#8217; directory and edit the configuration file &#8216;config.inc.php&#8217; by typing :<\/p>\n<p class=\"command\">cd \/etc\/phppgadmin\/<br \/>vim config.inc.php<\/p>\n<p>Find the line &#8216;$conf[&#8216;extra_login_security&#8217;] = true;&#8217; and change the value to &#8216;false&#8217; so you can login to phpPgAdmin with user postgres.<\/p>\n<pre>$conf['extra_login_security'] = false;<\/pre>\n<p>Save and exit.<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-2.png\" alt=\"Configure phpPgAdmin\" width=\"500\" height=\"111\" title=\"\"><\/a><\/p>\n<p>Now restart the PostgreSQL and Apache2 services.<\/p>\n<p class=\"command\">systemctl restart posqtgresql<br \/>systemctl restart apache2<\/p>\n<h2 id=\"step-testing-postgres\">Step 5 &#8211; Testing Postgres<\/h2>\n<p>By default, PostgreSQL is running on port &#8216;5432&#8217;, and the Apache2 running on the default HTTP port &#8217;80&#8217;.<\/p>\n<p>Check using netstat command.<\/p>\n<p class=\"command\">netstat -plntu<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-3.png\" alt=\"Check postgres network\" width=\"500\" height=\"154\" title=\"\"><\/a><\/p>\n<p>Now access phpPgAdmin with your browser http:\/\/yourip\/phppgadmin\/.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-4.png\" alt=\"Login to phpPgAdmin\" width=\"500\" height=\"189\" title=\"\"><\/a><\/p>\n<p>and then try login to with user &#8216;postgres&#8217; and your password.<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-5.png\" alt=\"Login with postgres user to phpPgAdmin\" width=\"500\" height=\"136\" title=\"\"><\/a><\/p>\n<p>After logging in, you will get this phpPgAdmin dashboard interface:<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_install_postgresql_and_phppgadmin_on_ubuntu_1804\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-6.png\" alt=\"phpPgAdmin dashboard interface\" width=\"500\" height=\"192\" title=\"\"><\/a><\/p>\n<p>The installation of PostgreSQL database with phpPgAdmin on ubuntu 18.04 has been completed successfully.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>PostgreSQL is an advanced object-relational database management system (ORDBMS). It is Open Source and has a large and active Community. PostgreSQL provides the psql command line program as primary front-end, which can be used to enter SQL queries directly or execute them from a file. phpPgAdmin is a web-based administration tool for PostgreSQL written in PHP that makes the administration of Postgres databases easier.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-postgresql-installation%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-7.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-postgresql-installation%2F&amp;text=How+to+Install+PostgreSQL+and+phpPgAdmin+on+Ubuntu+18.04&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-8.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-9.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-postgresql-installation%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-install-postgresql-and-phppgadmin-on-ubuntu-18-04-10.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features. PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows. PhpPgAdmin is a PHP-based web application for managing PostgreSQL databases. With [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4939","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=4939"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4939\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}