Website logo
⌘
K
VPS HostingDedicated ServerBlogContact
EDIS Global Documentation
Getting Started
Check your Inbox
Linux Secure Shell (SSH)
Windows Remote Desktop
Backups
Acceptable Use Policy (AUP)
VPS Management
FAQ
Advanced Setup Guides
Misc
Docs powered by Archbee
Advanced Setup Guides

How to Install LAMP with PostgreSQL and PostGIS

12min

How to Install LAMP with PostgreSQL and PostGIS on Ubuntu

Welcome to EDIS Global VPS Hosting's comprehensive guide on setting up a LAMP environment but with a twist - we're swapping out the MySQL component for PostgreSQL and its spatial extension, PostGIS.

Prerequisites:

  1. An active EDIS Global VPS Hosting account.
  2. A VPS running Ubuntu 20.04 or later.
  3. Basic knowledge of terminal operations.

Step-by-step Installation:

1. System Update:

Always ensure your server is up-to-date with the latest packages:

Text
sudo apt update && sudo apt upgrade -y


2. Apache Installation:

Begin by installing the Apache web server:

Text
sudo apt install apache2 -y


To check Apache's status:

Text
sudo systemctl status apache2


3. PHP Installation:

To install PHP and necessary extensions:

Text
sudo apt install php libapache2-mod-php php-pgsql -y


Verify the PHP installation:

Text
php -v


4. PostgreSQL and PostGIS Installation:

Install PostgreSQL along with some contrib packages:

Text
sudo apt install postgresql postgresql-contrib -y


Check the status of PostgreSQL:

Text
sudo systemctl status postgresql


Now, install PostGIS:

Text
sudo apt install postgis postgresql-<VERSION>-postgis-3 -y


Note: Replace <VERSION> with your PostgreSQL version, e.g., 13 for PostgreSQL 13.

5. Database Setup:

Switch to the postgres user and enter the PostgreSQL environment:

Text
sudo -u postgres psql


Now, create your database and enable PostGIS on it:

SQL
CREATE DATABASE your_database_name;
\c your_database_name
CREATE EXTENSION postgis;


(Optional) To create a new user:

SQL
CREATE USER your_user_name WITH ENCRYPTED PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_user_name;


6. Securing Your Installation:

While setting up, always remember to secure your installations:

  • For Apache: Set up firewalls, disable directory listings, and use SSL certificates.
  • For PostgreSQL: Change default PostgreSQL user passwords, restrict remote access, and regularly backup your database.
  • Regularly update all components of your stack.

Conclusion:

You've successfully set up a LAMP stack with PostgreSQL and PostGIS on your EDIS Global VPS! This hybrid setup allows you to harness the power of traditional web hosting with the spatial capabilities of PostGIS. Always ensure to monitor, maintain, and back up your server for optimal performance and safety.

Remember, EDIS Global is here to support you every step of the way. For more tutorials and support, visit our knowledge base or contact our dedicated support team.

Updated 06 Dec 2023
Did this page help you?
PREVIOUS
Reset Administrator Password on Windows Server
NEXT
GUI versions of Ubuntu or Debian
Docs powered by Archbee
TABLE OF CONTENTS
Prerequisites:
Step-by-step Installation:
1. System Update:
2. Apache Installation:
3. PHP Installation:
4. PostgreSQL and PostGIS Installation:
5. Database Setup:
6. Securing Your Installation:
Conclusion:
Docs powered by Archbee