Category Archives: PostgreSQL

Install PHP + Nginx and PostgreSQL

Install PHP, Here if you want to install any specific version just add php version after php for example: if you want to install php version 7.1 then just do it by this command sudo apt install php7.1 or leave it only php to get latest version of php.

Step 1: Install php latest version

//example for php 7.1:  sudo apt install php7.1
sudo apt install php 
sudo apt install php-fpm 
sudo apt install php-apcu 
sudo apt install php-curl 
sudo apt install php-cli 
sudo apt install php-pgsql 
sudo apt install php-gd 
sudo apt install php-mcrypt 
sudo apt install php-mbstring 
sudo apt install php-intl

Step 2: Improve security
Improve security by editing /etc/php//fpm/php.ini and modifying pathinfo to 0

sudo nano /etc/php//fpm/php.ini

set it 0

cgi.fix_pathinfo=0  

Step 3: Restart PHP

sudo systemctl restart php7.1-fpm

Step 4: Installing the above PHP packages will pull in apache packages that are not required. Remove

sudo apt --purge remove *apache*

Step 5: Install Nginx

//Install NGINX
sudo apt install nginx-common
sudo apt install nginx                                                    
sudo systemctl start nginx

Step 6: Install Nginx
Installing the above PHP packages will pull in apache packages that are not required. Remove

sudo apt --purge remove *apache*
//Install NGINX
sudo apt install nginx-common
sudo apt install nginx                                                    
sudo systemctl start nginx

For More : php-nginx-postgresql

How To Install and Use PostgreSQL on Ubuntu

Introduction
Relational database management systems are a key component of many websites and applications. They provide a structured way to store, organize, and access information.

PostgreSQL, or Postgres, is a relational database management system that provides an implementation of the SQL querying language. It is a popular choice for many small and large projects and has the advantage of being standards-compliant and having many advanced features like reliable transactions and concurrency without reading locks.

In this guide, we will demonstrate how to install Postgres on an Ubuntu 16.04 VPS instance and go over some basic ways to use it.

Installation
Ubuntu’s default repositories contain Postgres packages, so we can install these easily using the apt packaging system.

Since this is our first time using apt in this session, we need to refresh our local package index. We can then install the Postgres package and a -contrib package that adds some additional utilities and functionality:

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

Now that our software is installed, we can go over how it works and how it may be different from similar database management systems you may have used.

To check the config directory of PostgreSQL

 ls /etc/postgresql/10/main/ 

To see the commands to control postgresql service

 service postgresql 

The output should be:
Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..]

So now if you want to know the status of postgresql just run the command

  service postgresql status

To change postgres user password just like root user for mysql

 ALTER USER postgres WITH PASSWORD 'dbuser123'; 

To create a new user name with mydbuser_1

 CREATE USER mydbuser_1 WITH PASSWORD 'dbuser123';  

To see the user list

 \du  

Change the permission for the newly created user

 ALTER USER mydbuser_1 WITH SUPERUSER; 

For more
1. ProgrammingKnowledge.
2. how-to-install-and-use-postgresql-on-ubuntu.