{"id":2064,"date":"2024-04-22T05:58:57","date_gmt":"2024-01-30T19:37:26","guid":{"rendered":""},"modified":"2025-02-02T00:46:18","modified_gmt":"2025-02-01T23:46:18","slug":"how-to-install-pghero-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-pghero-on-ubuntu-22-04\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 PgHero on Ubuntu 22.04"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<header>\n<h1>\u00a0<\/h1>\n<\/header>\n<article>\n<p><strong>PgHero<\/strong> is a powerful tool for monitoring PostgreSQL databases, providing insights into slow queries, index usage, cache hit rates, and more. In this guide, we will show you how to install PgHero on <strong>Ubuntu 22.04<\/strong> to monitor your PostgreSQL databases efficiently. Hosting your database on a  ensures optimal performance and scalability, thanks to the dedicated resources of a <strong>VPS server<\/strong>.<\/p>\n<h2>Step 1: Update Your VPS Server<\/h2>\n<p>Before installing PgHero, make sure your <a href=\"https:\/\/ie.netcloud24.com\">VPS server<\/a> is up to date. Run the following commands to update the system:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n<p>By hosting your PostgreSQL and PgHero setup on a <strong>Windows VPS<\/strong>, you gain better performance, allowing you to monitor and optimize your database with greater efficiency.<\/p>\n<h2>Step 2: Install PostgreSQL<\/h2>\n<p>If you haven&#8217;t already installed PostgreSQL on your server, you can do so with the following command:<\/p>\n<pre><code>sudo apt install postgresql postgresql-contrib -y<\/code><\/pre>\n<p>Once installed, PostgreSQL will start automatically. You can verify that it\u2019s running using:<\/p>\n<pre><code>sudo systemctl status postgresql<\/code><\/pre>\n<h2>Step 3: Install PgHero<\/h2>\n<p>Next, we will install PgHero. First, you need to install Ruby and other dependencies. Run the following commands:<\/p>\n<pre><code>sudo apt install ruby-full -y<\/code><\/pre>\n<p>Now, install the PgHero gem:<\/p>\n<pre><code>sudo gem install pghero<\/code><\/pre>\n<h2>Step 4: Set Up PgHero with PostgreSQL<\/h2>\n<p>After installing PgHero, you need to configure it with your PostgreSQL database. First, switch to the PostgreSQL user:<\/p>\n<pre><code>sudo -i -u postgres<\/code><\/pre>\n<p>Then, access the PostgreSQL shell:<\/p>\n<pre><code>psql<\/code><\/pre>\n<p>In the shell, create the <code>pghero<\/code> extension on your database:<\/p>\n<pre><code>\r\nCREATE EXTENSION pghero;\r\n\\q\r\n<\/code><\/pre>\n<p>This will install the PgHero extension on your PostgreSQL database.<\/p>\n<h2>Step 5: Set Up PgHero Web Interface<\/h2>\n<p>To access PgHero via a web interface, you need to configure it to run as a web application. First, install a web server like <strong>Puma<\/strong> to run the PgHero web interface. Install Puma by running:<\/p>\n<pre><code>sudo gem install puma<\/code><\/pre>\n<p>Create a new directory for PgHero and navigate into it:<\/p>\n<pre><code>\r\nmkdir ~\/pghero_app &amp;&amp; cd ~\/pghero_app\r\n<\/code><\/pre>\n<p>Create a basic configuration file for PgHero:<\/p>\n<pre><code>nano config.ru<\/code><\/pre>\n<p>Add the following content to the file:<\/p>\n<pre><code>\r\nrequire \"pghero\"\r\nrun PgHero::App\r\n<\/code><\/pre>\n<p>Start the PgHero web interface using Puma:<\/p>\n<pre><code>puma -p 8080<\/code><\/pre>\n<p>You can now access the PgHero interface by visiting <code>http:\/\/your-server-ip:8080<\/code> in your browser.<\/p>\n<h2>Step 6: Set Up Systemd Service for PgHero<\/h2>\n<p>To keep PgHero running as a background service, it\u2019s best to create a Systemd service. Create a service file by running:<\/p>\n<pre><code>sudo nano \/etc\/systemd\/system\/pghero.service<\/code><\/pre>\n<p>Add the following content to the file:<\/p>\n<pre><code>\r\n[Unit]\r\nDescription=PgHero Monitoring Tool\r\nAfter=network.target\r\n\r\n[Service]\r\nUser=your-username\r\nWorkingDirectory=\/home\/your-username\/pghero_app\r\nExecStart=\/usr\/local\/bin\/puma -p 8080\r\nRestart=always\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>Save the file, then reload Systemd and start the PgHero service:<\/p>\n<pre><code>\r\nsudo systemctl daemon-reload\r\nsudo systemctl start pghero\r\nsudo systemctl enable pghero\r\n<\/code><\/pre>\n<h2>Step 7: Access PgHero<\/h2>\n<p>After setting up the service, PgHero will run continuously, and you can access it by visiting <code>http:\/\/your-server-ip:8080<\/code>. From the web interface, you can monitor slow queries, index usage, cache hit rates, and more.<\/p>\n<h2>Step 8: Optimize Your VPS Server for PgHero<\/h2>\n<p>To ensure the best performance for monitoring and optimizing your PostgreSQL database, hosting PgHero on a  is highly recommended. A <strong>VPS server<\/strong> provides dedicated resources such as CPU, memory, and storage, which are essential for handling large databases and ensuring that PgHero delivers real-time insights into your database performance.<\/p>\n<h2>Conclusion<\/h2>\n<p>Installing PgHero on Ubuntu 22.04 allows you to monitor and optimize your PostgreSQL database with ease. By hosting your PostgreSQL and PgHero setup on a , you can take full advantage of dedicated resources, ensuring that your database performs optimally even under heavy workloads.<\/p>\n<p>For more information about VPS hosting and optimizing your PostgreSQL database with PgHero, visit  today.<\/p>\n<\/article>\n<footer>\n<p>\u00a9 2024 Windows VPS &#8211; All Rights Reserved<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 PgHero is a powerful tool for monitoring PostgreSQL databases, providing insights into slow queries, index usage, cache hit rates, and more. In this guide, we will\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-2064","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=2064"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2064\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=2064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=2064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=2064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}