0

I want to deploy my laravel app in ubuntu server 18 LTS. So I have install nginx postgres php. But when i try to do php artisan migrate I have this returned error :

This is the errror (a picture beacose of comande line) .

So I have verify different thing : First I can access to my data base in localhost with the postgres user. The laravel app work while database not be required.

In php.ini I have uncomment extention=pdo-pgsql; and extention=pgsql

I have install the php postgres sql extension with this command sudo apt-get install php7.2-pgsql

And this is my .env settings for database in laravel :

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5433
DB_DATABASE=THERY //I have already create the database
DB_USERNAME=postgres
DB_PASSWORD=postgres

12
  • Try restarting the server or even the instance. Commented Feb 19, 2020 at 8:07
  • I have just try to reboot same and same error Commented Feb 19, 2020 at 8:10
  • Where is the database hosted? Commented Feb 19, 2020 at 8:11
  • On the same machine as the web server Commented Feb 19, 2020 at 8:12
  • Try DB_HOST=localhost instead of DB_HOST=127.0.0.1 in your .env. Commented Feb 19, 2020 at 8:14

2 Answers 2

3

So for my problem they have two solution plus a bonus

  1. If the problem come from php and you don't want to reinstall all you can follow this topic here in ask ubuntu and use this two command :
sudo apt-get --purge remove php-common

sudo apt-get install php-common php-pgsql php-cli
  1. If you want to correctly install php for laravel with postgresql you can use this comandes:
#php install comande
sudo apt-get install php-fpm openssl php-common php-curl php-json php-mbstring php-xml php-zip php-pgsql

#make sure to uncomment extension=pdo_pgsql
sudo nano /etc/php/7.2/fpm/php.ini 

#restart fpm service to apply settings
sudo systemctl restar php7.2-fpm

Finally if you have an [SQLSTATE 08006 error] check if the port in .env file in your laravel app correspond to the listened port in your server (form me the used port is 5432 and not 5433)

Sign up to request clarification or add additional context in comments.

Comments

1

There may be different issues for your problem. Any of the below may be occured:

  1. php PGsql is not installed. install it by
apt-get install php-pgsql
  1. PGsql library is missing in the composer. install it by
composer require asmiarowski/laravel-postgres // There are multiple librariies available in packagist
  1. Your config in .env are not cached. you can cache them by running command
php artisan config:cache
  1. Your PGSql server is not reachable. you can take further action to resolve them.

6 Comments

linux don't find php7.3-pgsql It work if I use 7.2 ?
You can install "php-pgsql" or "php7.2-pgsql (if your PHP version is 7.2)" to use system reliable pgsql according to the installed PHP version. the answer was for representational purposes.
@MrSolarius What is your PHP version on CLI and on WebServer(Apache) ?
That have not work I have this return error Unable to load dynamic library "pdo_pgsql' (tried: /usr/lib/php/20170718/pdo_pgsql (/usr/llb/php/20170718/pdo_pg /usr/lib/php/20170718/pdo_pgsql.so: undefined symbol: pdo parse_params)) in Unknown on line o PHP Warning: Module 'pgsql" already loaded in Unknown on line 0
apt-get install php-pgsql should resolve the issue. can you paste a snapshot of phpinfo() page ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.