3

I need to install postgresql and phppgadmin with nginx installed under ubuntu 16(AWS) I installed packages :

$ sudo apt-get -y install postgresql postgresql-contrib phppgadmin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
phppgadmin is already the newest version (5.1+ds-1ubuntu1).
postgresql is already the newest version (9.5+173ubuntu0.2).
postgresql-contrib is already the newest version (9.5+173ubuntu0.2).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.

in phpinfo I see drivers installed http://ec2-18-224-82-207.us-east-2.compute.amazonaws.com/info.php

PostgreSQL driver for PDO   Edin Kadribasic, Ilia Alshanetsky
PostgreSQL  Jouni Ahto, Zeev Suraski, Yasuo Ohgaki, Chris Kings-Lynne

But running phppgadmin in url like : http://ec2-18-224-82-207.us-east-2.compute.amazonaws.com/phppgadmin I got error :

404 Not Found
nginx/1.10.3 (Ubuntu)

Searching for decision I found that /etc/nginx/sites-available/phppgadmin directory, but :

$ cd /etc/nginx/sites-available
ubuntu@ip-172-31-34-88:/etc/nginx/sites-available$ ls -la
total 16
drwxr-xr-x 2 root root 4096 Jun 18 05:15 .
drwxr-xr-x 6 root root 4096 Jun 12 15:46 ..
-rw-r--r-- 1 root root 2327 Jun 17 12:02 default
-rw-r--r-- 1 root root 2074 Jun 12 15:49 default.bak

Which steps I have to take to run phppgadmin and laravel 5 app ?

Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91

1 Answers1

2

1. Installation

First, install postgreSQL and phpPgAdmin.

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib phppgadmin php5-fpm

And then, lets install Nginx.

sudo apt-get install nginx

This should automatically start Nginx as the web server. You could also type this to start the service.

sudo service nginx start

2. Setup PostgreSQL & phpPgAdmin

First login as the Postgres user and lets create a new Postgres role (user)

sudo su postgres
createuser -P --interactive

--interactive - adds some initial permissions -P - means assign a password

The default installation of phpPgAdmin will automatically connect to PostgreSQL server. Unless you have modified any configuration, you can leave this as is.

3. Setup Nginx

First, lets add a symbolic link to the directory where you intend to place all your web files in.

sudo ln -s /usr/share/webapps/phppgadmin /path/to/your/www

Next, lets create a server block for phpPgAdmin. Create a file /etc/nginx/sites-available/phppgadmin with the following contents.

# Server block for phppgadmin service
server{
        server_name     phppgadmin.example.com;
        root            /path/to/your/www/phppgadmin;

        access_log      /var/log/phppgadmin/access.log;
        error_log       /var/log/phppgadmin/error.log;

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /path/to/your/www/postgres$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }
}

By default Nginx includes all the servers in the folder /etc/nginx/sites-enabled. So lets add a symbolic link to the new server we created to let nginx know about our new server!

sudo ln -s /etc/nginx/sites-available/phppgadmin /etc/nginx/sites-enabled/

Now all that is left to do is to restart/reload Nginx and our phpPgAdmin is ready to go!

sudo service nginx restart

Make sure you've included theese in nginx.conf file.

index   index.php index.htm index.html;
root    /usr/share/nginx/html;