AWS Documentation

⌘K
  1. Home
  2. Docs
  3. AWS Documentation
  4. AWS LEPP on Ubuntu 22 (PostgreSQL) with PHP 8.2 by Classmethod

AWS LEPP on Ubuntu 22 (PostgreSQL) with PHP 8.2 by Classmethod

This AMI is a LEMP Web Server with phpMyAdmin installed on Ubuntu 22. Also the SSM agent and AWS CLI is installed. If you want to use it, please refer to documents.

This AMI supports following versions.

  • PHP 8.2
  • Nginx 1.22
  • PostgreSQL 14

Web Server

You can access to top page using http://. We installed certbot from snap packages, you can set up TLS/SSL certificates using Let’s Encrypt.

PHP Modules

If you are installing additional required PHP modules, install them with php version. For instance,

$ sudo apt install php8.2-mbstring

DB Server

You can find the password from EC2 management console System Log.

  1. Go to Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. Chose your Instance and Click Actions → Instance Settings → Get System log

Get System log

You can also SSH into your instance and find the login credential using the following command.

[ec2-user@ip-172-31-77-125 ~]$ cat credentials 
////////////////////credentials info////////////////////
--- PostgreSQL
----- User : postgres
----- Password : aVpwwo9pdiK1lewp
////////////////////////////////////////////////////////

Login PostgreSQL SHELL

$ sudo -i -u postgres psql -U postgres
psql (14.6 (Ubuntu 14.6-0ubuntu0.22.04.1))
Type "help" for help.

postgres=# SHOW data_directory;
data_directory
-----------------------------
/var/lib/postgresql/14/main
(1 row)

postgres=#

or

$ psql -h localhost -U postgres
Password for user postgres:
psql (14.6 (Ubuntu 14.6-0ubuntu0.22.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=# SELECT version();
version
--------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.6 (Ubuntu 14.6-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, 64-bit
(1 row)

postgres=#

Option pgAdmin 4

You can access to PostgreSQL using pgAdmin 4 with ssh tunnel.

Dashboard

Click Add New Server

General

Type Your DB Server Name

SSH Tunnel

Click SSH Tunnel Tab

  • Use SSH tunneling: On
  • Tunnel host: your server ip address
  • Tunnel port: 22
  • Authentication: Identity file
  • Identity file: *****.pem

Connection

Click Connection Tab

  • Host name/address: localhost
  • Port: 5432
  • Maintenance database: postgres
  • Username: postgres
  • Password: *******

Click Save

Let’s use pgAdmin

Reference

Tags , ,

How can we help?