我想在ubuntu服务器18 LTS中部署我的laravel应用。所以我已经安装了nginx postgres php。但是,当我尝试执行php artisan migrate
时,出现此返回错误:
This is the errror (a picture beacose of comande line)。
所以我已经验证了另一件事:首先,我可以使用postgres用户访问本地主机中的数据库。laravel应用程序无需数据库即可工作。
在php.ini中,我没有注释extention=pdo-pgsql;
和extention=pgsql
我已使用此命令sudo apt-get install php7.2-pgsql
安装php postgres sql扩展名
这是我在laravel中数据库的.env设置:
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
因此,对于我的问题,他们有两个解决方案和一个额外的奖励
sudo apt-get --purge remove php-common
sudo apt-get install php-common php-pgsql php-cli
#php install comande
sudo apt-get insatall 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
最后,如果出现[SQLSTATE 08006错误],请检查laravel应用中.env文件中的端口是否与服务器中的侦听端口相对应(形成我使用的端口为5432,而不是5433)
您的问题可能有不同的问题。可能发生以下任何情况:
apt-get install php-pgsql
composer require asmiarowski/laravel-postgres // There are multiple librariies available in packagist
php artisan config:cache