I have a Symfony2 project under Debian. What are the steps to change my database to postgresql ?
Note: The question has been asked here, but it is with symfony 1.4, I believe.
Install postgresql under debian:
apt-get install postgresql postgresql-client
apt-get install php5-pgsql
adduser mypguser
su - postgres
psql
CREATE USER mypguser WITH PASSWORD 'mypguserpass';
CREATE DATABASE mypgdatabase;
GRANT ALL PRIVILEGES ON DATABASE mypgdatabase to mypguser;
\q
In /etc/php5/apache2/php.ini, add: (this is in fact optional)
extension=pdo.so
extension=php_pdo_pgsql.so
Change the symfony apps/config/paramters.ini file:
[parameters]
database_driver: pdo_pgsql
database_host: localhost
database_port: null
database_name: mypgdatabase
database_user: mypguser
database_password: mypguserpass
Relaod your project:
php bin/vendors update
php app/console assets:install web
php app/console doctrine:schema:create
php app/console doctrine:fixtures:load
chmod 777 -R app/cache app/logs
You're done!
References:
Symfony documentation for configuring databases
Postgresql installation under debian
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With