AWS EC2 first install, ssh and postgresql
Open your EC2 instances
Click networking add new rule. i added inbound and outbound 0.0.0.0. this (is not safe please check your security setting on your demand.)
click connect, on tab you can see ssh connection.
fill up serverhost public dns, username and find your pem file in your local drive which you created while you create EC2 instance.
Connect ssh
it is time to install postgresql.
Write the code to your ssh console
sudo apt-get install
sudo apt install postgresql
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following additional packages will be installed:
libcommon-sense-perl libjson-perl libjson-xs-perl libllvm17t64 libpq5 libtypes-serialiser-perl postgresql-16 postgresql-client-16 postgresql-client-common postgresql-common ssl-cert
Suggested packages:
postgresql-doc postgresql-doc-16
The following NEW packages will be installed:
libcommon-sense-perl libjson-perl libjson-xs-perl libllvm17t64 libpq5 libtypes-serialiser-perl postgresql postgresql-16 postgresql-client-16 postgresql-client-common postgresql-common ssl-cert
0 upgraded, 12 newly installed, 0 to remove and 25 not upgraded.
Need to get 16.9 MB/43.5 MB of archives.
After this operation, 175 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 libpq5 amd64 16.4–0ubuntu0.24.04.1 [141 kB]
Get:2 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 postgresql-client-16 amd64 16.4–0ubuntu0.24.04.1 [1271 kB]
Get:3 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 postgresql-16 amd64 16.4–0ubuntu0.24.04.1 [15.5 MB]
Fetched 16.9 MB in 0s (54.9 MB/s)
Preconfiguring packages …
Selecting previously unselected package libjson-perl.
(Reading database … 67741 files and directories currently installed.)
Preparing to unpack …/00-libjson-perl_4.10000–1_all.deb …
Unpacking libjson-perl (4.10000–1) …
Selecting previously unselected package postgresql-client-common.
Preparing to unpack …/01-postgresql-client-common_257build1_all.deb …
Unpacking postgresql-client-common (257build1) …
Selecting previously unselected package ssl-cert.
Preparing to unpack …/02-ssl-cert_1.1.2ubuntu1_all.deb …
Unpacking ssl-cert (1.1.2ubuntu1) …
Selecting previously unselected package postgresql-common.
Preparing to unpack …/03-postgresql-common_257build1_all.deb …
Adding ‘diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common’
Unpacking postgresql-common (257build1) …
Selecting previously unselected package libcommon-sense-perl:amd64.
Preparing to unpack …/04-libcommon-sense-perl_3.75–3build3_amd64.deb …
Unpacking libcommon-sense-perl:amd64 (3.75–3build3) …
Selecting previously unselected package libtypes-serialiser-perl.
Preparing to unpack …/05-libtypes-serialiser-perl_1.01–1_all.deb …
Unpacking libtypes-serialiser-perl (1.01–1) …
Selecting previously unselected package libjson-xs-perl.
Preparing to unpack …/06-libjson-xs-perl_4.030–2build3_amd64.deb …
Unpacking libjson-xs-perl (4.030–2build3) …
Selecting previously unselected package libllvm17t64:amd64.
Preparing to unpack …/07-libllvm17t64_1%3a17.0.6–9ubuntu1_amd64.deb …
Unpacking libllvm17t64:amd64 (1:17.0.6–9ubuntu1) …
Selecting previously unselected package libpq5:amd64.
Preparing to unpack …/08-libpq5_16.4–0ubuntu0.24.04.1_amd64.deb …
Unpacking libpq5:amd64 (16.4–0ubuntu0.24.04.1) …
Selecting previously unselected package postgresql-client-16.
Preparing to unpack …/09-postgresql-client-16_16.4–0ubuntu0.24.04.1_amd64.deb …
Unpacking postgresql-client-16 (16.4–0ubuntu0.24.04.1) …
Selecting previously unselected package postgresql-16.
Preparing to unpack …/10-postgresql-16_16.4–0ubuntu0.24.04.1_amd64.deb …
Unpacking postgresql-16 (16.4–0ubuntu0.24.04.1) …
Selecting previously unselected package postgresql.
Preparing to unpack …/11-postgresql_16+257build1_all.deb …
Unpacking postgresql (16+257build1) …
Setting up postgresql-client-common (257build1) …
Setting up libpq5:amd64 (16.4–0ubuntu0.24.04.1) …
Setting up libcommon-sense-perl:amd64 (3.75–3build3) …
Setting up libllvm17t64:amd64 (1:17.0.6–9ubuntu1) …
Setting up ssl-cert (1.1.2ubuntu1) …
Created symlink /etc/systemd/system/multi-user.target.wants/ssl-cert.service → /usr/lib/systemd/system/ssl-cert.service.
Setting up libtypes-serialiser-perl (1.01–1) …
Setting up libjson-perl (4.10000–1) …
Setting up libjson-xs-perl (4.030–2build3) …
Setting up postgresql-client-16 (16.4–0ubuntu0.24.04.1) …
update-alternatives: using /usr/share/postgresql/16/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (257build1) …
Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages…
Removing obsolete dictionary files:
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.
Setting up postgresql-16 (16.4–0ubuntu0.24.04.1) …
Creating new PostgreSQL cluster 16/main …
/usr/lib/postgresql/16/bin/initdb -D /var/lib/postgresql/16/main — auth-local peer — auth-host scram-sha-256 — no-instructions
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.
The database cluster will be initialized with locale “C.UTF-8”.
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/16/main … ok
creating subdirectories … ok
selecting dynamic shared memory implementation … posix
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default time zone … Etc/UTC
creating configuration files … ok
running bootstrap script … ok
performing post-bootstrap initialization … ok
syncing data to disk … ok
Setting up postgresql (16+257build1) …
Processing triggers for man-db (2.12.0–4build2) …
Processing triggers for libc-bin (2.39–0ubuntu8.2) …
Scanning processes…
Scanning linux images…
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.