Ubuntu php with postgresql

How To Install php8.1-pgsql on Ubuntu 22.04

In this tutorial we learn how to install php8.1-pgsql on Ubuntu 22.04.

What is php8.1-pgsql

This package provides the PostgreSQL module(s) for PHP.

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

There are three ways to install php8.1-pgsql on Ubuntu 22.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install php8.1-pgsql Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install php8.1-pgsql using apt-get by running the following command:

sudo apt-get -y install php8.1-pgsql 

Install php8.1-pgsql Using apt

Update apt database with apt using the following command.

After updating apt database, We can install php8.1-pgsql using apt by running the following command:

sudo apt -y install php8.1-pgsql 

Install php8.1-pgsql Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

After updating apt database, We can install php8.1-pgsql using aptitude by running the following command:

sudo aptitude -y install php8.1-pgsql 

How To Uninstall php8.1-pgsql on Ubuntu 22.04

To uninstall only the php8.1-pgsql package we can use the following command:

sudo apt-get remove php8.1-pgsql 

Uninstall php8.1-pgsql And Its Dependencies

To uninstall php8.1-pgsql and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove php8.1-pgsql 

Remove php8.1-pgsql Configurations and Data

To remove php8.1-pgsql configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge php8.1-pgsql 

Remove php8.1-pgsql configuration, data, and all of its dependencies

We can use the following command to remove php8.1-pgsql configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge php8.1-pgsql 

References

Summary

In this tutorial we learn how to install php8.1-pgsql package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.

Источник

How to install LAPP (Apache + PHP + PostgreSQL) on Ubuntu 20.04

There are many combinations of programs and servers in Linux. Of all of them, the LAMP or LEMP stack is one of the most known and popular but some prefer PostgreSQL over MariaDB / MySQL. So, in this post, you will learn how to install the LAPP stack on Ubuntu 20.04

This stack also provides us with a functional server but with a different database manager like PostgreSQL. This database handler is maybe the most powerful in the world in open source. So it is normal that many want to make the change.

How to install LAPP on Ubuntu 20.04

1.- Install Apache web server on Ubuntu 20.04

The first step is to install the Apache webserver which is one of the most secure and reliable servers within Linux. Together with Nginx, they are one of the most popular in the world.

So, open a terminal or SSH session and run it:

Then, start the service and enable it to start with the system:

sudo systemctl start apache2
sudo systemctl enable apache2

Finally, you can open a web browser and go to the following address http://your-server or http://ip-server and you will see Apache’s default page.

Apache Default page on Ubuntu 20.04

This indicates that the installation has been successful.

2.- Install PHP on Ubuntu 20.04

Now the next component is PHP which is a very popular programming language in the web environment. Therefore, it must be installed along with some of its fundamental modules.

php7.4 libapache2-mod-php7.4 openssl php-imagick php7.4-common php7.4-curl php7.4-gd php7.4-imap php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring php7.4-pgsql php-ssh2 php7.4-xml php7.4-zip unzip

Now to prove that PHP and Apache are working properly, let’s make a test file.

sudo nano /var/www/html/test.php

And add the following content:

Save the changes and close the editor.

sudo systemctl restart apache2

Then open it from your web browser, for example http://your-server/test.php

PHPinfo method

If you manage to see a page with the PHP information, then both are working correctly.

3.- Install PostgreSQL on Ubuntu 20.04

PostgreSQL is one of the most advanced and modern relational database managers out there. It is always shown as the immediate competitor of MySQL and MariaDB in the segment of open source and community database managers.

One of the main advantages of using PostgreSQL is that it has extensive documentation and supports powerful features. All this in an open-source and free application.

Installing PostgreSQL is quite simple and we explain it in detail in this post:

And so you have the LAPP stack ready to work.

Conclusion

The LAMP stack is one of the popular and famous ones that exist but it is not the only one. Now we present you an alternative that changes to MySQL / MariaDB by PostgreSQL in a fast and easy way and forming the LAPP stack that is quite used too

Источник

Читайте также:  How to Import SQL File in Mysql Database using PHP
Оцените статью