<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged apache</title>
<link>https://coderlegion.com/tag/apache</link>
<description>Powered by Question2Answer</description>
<item>
<title>Kafka in hospitals: real-world event architecture for HIS, LIS and billing in a Venezuelan mid-size</title>
<link>https://coderlegion.com/23724/kafka-hospitals-real-world-event-architecture-for-his-lis-and-billing-venezuelan-mid-size</link>
<description>&lt;p&gt;Most Kafka “healthcare interoperability” examples are theoretical or focused on US/EU EHRs. I wanted to share a concrete case from a mid‑size hospital in Venezuela where we used Kafka as the event backbone between HIS, LIS and billing systems.&lt;/p&gt;
&lt;p&gt;Context:&lt;/p&gt;
&lt;p&gt;4–8 systems needed to know the same things in near real time: admissions, lab results, charges.&lt;/p&gt;
&lt;p&gt;Point‑to‑point integrations had become a mess: custom scripts, duplicate records, fragile error handling.&lt;/p&gt;
&lt;p&gt;The hospital knew it would keep adding systems (BI, SAP, new clinical modules) over the next few years.&lt;/p&gt;
&lt;p&gt;What we ended up doing:&lt;/p&gt;
&lt;p&gt;Defined topics by clinical domain (admissions, lab-results, orders, billing-events) instead of “one topic for everything”.&lt;/p&gt;
&lt;p&gt;Partitioned by patient or encounter ID to preserve clinical event order per case.&lt;/p&gt;
&lt;p&gt;Used replication factor 3 and min.insync.replicas=2 because losing a lab result is not just a business data issue.&lt;/p&gt;
&lt;p&gt;Enabled idempotent + transactional producers (exactly-once semantics) for lab results and financial events, where duplicates are harmful.&lt;/p&gt;
&lt;p&gt;The article goes into more detail on:&lt;/p&gt;
&lt;p&gt;How we mapped HL7/FHIR messages to Kafka topics.&lt;/p&gt;
&lt;p&gt;Trade‑offs in infra cost vs. resilience for a hospital context.&lt;/p&gt;
&lt;p&gt;When Kafka was clearly the wrong tool (small clinics with only 2–3 systems and low event volume).&lt;/p&gt;
&lt;p&gt;Link (in Spanish, but I’m happy to summarize or answer questions in English here):&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://codebymelendez.com/insights/apache-kafka-sistemas-hospitalarios&quot;&gt;Kafka in hospitals&lt;/a&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/23724/kafka-hospitals-real-world-event-architecture-for-his-lis-and-billing-venezuelan-mid-size</guid>
<pubDate>Wed, 29 Jul 2026 06:37:11 +0000</pubDate>
</item>
<item>
<title>Running Lightweight Services on Raspberry Pi: Build Powerful Mini Servers at Home</title>
<link>https://coderlegion.com/12517/running-lightweight-services-on-raspberry-pi-build-powerful-mini-servers-at-home</link>
<description>&lt;p&gt;The &lt;strong&gt;Raspberry Pi&lt;/strong&gt; has come a long way from being just a learning tool for beginners. Today, it’s powerful enough to run real services that developers, hobbyists, and DevOps engineers use every day.&lt;/p&gt;
&lt;p&gt;From hosting internal dashboards to running automation tools, the Raspberry Pi is perfect for &lt;strong&gt;lightweight services&lt;/strong&gt; that don’t require heavy infrastructure. With proper setup, this small single board computer can operate as a reliable mini server for development, monitoring, and home automation.&lt;/p&gt;
&lt;p&gt;In this guide, we’ll explore how to run lightweight services on Raspberry Pi, the types of applications that work best, and best practices for keeping your Pi fast, stable, and secure.&lt;/p&gt;
&lt;h3 id=&quot;why-use-a-raspberry-pi-for-lightweight-services-&quot;&gt;Why Use a Raspberry Pi for Lightweight Services?&lt;/h3&gt;
&lt;p&gt;Running services locally on a Raspberry Pi offers several advantages.&lt;/p&gt;
&lt;p&gt;First, it’s &lt;strong&gt;extremely cost effective&lt;/strong&gt;. Instead of paying for a cloud server every month, a Raspberry Pi can run continuously with minimal electricity usage.&lt;/p&gt;
&lt;p&gt;Second, it provides &lt;strong&gt;full control of your environment&lt;/strong&gt;. You can experiment, break things, and rebuild without affecting production systems.&lt;/p&gt;
&lt;p&gt;Third, it’s perfect for &lt;strong&gt;learning DevOps and system administration skills&lt;/strong&gt;. Managing services on a Raspberry Pi exposes you to Linux networking, containerization, monitoring, and automation.&lt;/p&gt;
&lt;p&gt;Many developers also use the Raspberry Pi as a &lt;strong&gt;personal infrastructure lab&lt;/strong&gt; where they test tools before deploying them to cloud servers.&lt;/p&gt;
&lt;h3 id=&quot;what-counts-as-a-lightweight-service-&quot;&gt;What Counts as a Lightweight Service?&lt;/h3&gt;
&lt;p&gt;A lightweight service is an application that requires minimal CPU, RAM, and disk resources. These services usually run quietly in the background and handle specific tasks.&lt;/p&gt;
&lt;p&gt;Examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Monitoring tools&lt;/li&gt;
&lt;li&gt;Web dashboards&lt;/li&gt;
&lt;li&gt;Local APIs&lt;/li&gt;
&lt;li&gt;Home automation systems&lt;/li&gt;
&lt;li&gt;DNS or ad blocking services&lt;/li&gt;
&lt;li&gt;IoT gateways&lt;/li&gt;
&lt;li&gt;Small databases&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Raspberry Pi is ideal for these because they don't require heavy processing power.&lt;/p&gt;
&lt;h3 id=&quot;choosing-the-right-raspberry-pi-setup&quot;&gt;Choosing the Right Raspberry Pi Setup&lt;/h3&gt;
&lt;p&gt;Before running services, make sure your Raspberry Pi is properly configured.&lt;/p&gt;
&lt;h4 id=&quot;recommended-hardware&quot;&gt;Recommended Hardware&lt;/h4&gt;
&lt;p&gt;For best results, use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Raspberry Pi 4 (4GB or 8GB RAM)&lt;/li&gt;
&lt;li&gt;Fast microSD card (Class 10 or better)&lt;/li&gt;
&lt;li&gt;Reliable power supply&lt;/li&gt;
&lt;li&gt;Optional SSD for better performance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A stable storage device is especially important because microSD cards can degrade with heavy read/write operations.&lt;/p&gt;
&lt;h4 id=&quot;operating-system&quot;&gt;Operating System&lt;/h4&gt;
&lt;p&gt;Most developers use &lt;strong&gt;Raspberry Pi OS Lite&lt;/strong&gt; for server environments. It’s lightweight, fast, and avoids unnecessary desktop components.&lt;/p&gt;
&lt;p&gt;Once installed, update the system:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Keeping your system updated ensures stability and security.&lt;/p&gt;
&lt;h3 id=&quot;lightweight-services-you-can-run-on-raspberry-pi&quot;&gt;Lightweight Services You Can Run on Raspberry Pi&lt;/h3&gt;
&lt;p&gt;Let’s explore some practical services developers commonly run on a Raspberry Pi.&lt;/p&gt;
&lt;h4 id=&quot;1-local-web-server&quot;&gt;1. Local Web Server&lt;/h4&gt;
&lt;p&gt;Running a small web server is one of the most common uses.&lt;/p&gt;
&lt;p&gt;You can install &lt;strong&gt;Nginx or Apache&lt;/strong&gt; and host:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;personal dashboards&lt;/li&gt;
&lt;li&gt;development APIs&lt;/li&gt;
&lt;li&gt;internal tools&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example installation:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt install nginx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once running, your Raspberry Pi becomes a small but capable web server for local applications.&lt;/p&gt;
&lt;h4 id=&quot;2-monitoring-and-metrics&quot;&gt;2. Monitoring and Metrics&lt;/h4&gt;
&lt;p&gt;Monitoring tools help you track system performance across your network.&lt;/p&gt;
&lt;p&gt;Popular lightweight options include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prometheus Node Exporter&lt;/li&gt;
&lt;li&gt;Grafana dashboards&lt;/li&gt;
&lt;li&gt;Uptime monitoring tools&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Running these locally allows you to monitor:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;server uptime&lt;/li&gt;
&lt;li&gt;CPU and memory usage&lt;/li&gt;
&lt;li&gt;network activity&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s a great way to learn observability practices used in production environments.&lt;/p&gt;
&lt;h4 id=&quot;3-home-automation-services&quot;&gt;3. Home Automation Services&lt;/h4&gt;
&lt;p&gt;The Raspberry Pi is widely used for &lt;strong&gt;home automation platforms&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Tools like Home Assistant allow you to connect and control:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;smart lights&lt;/li&gt;
&lt;li&gt;thermostats&lt;/li&gt;
&lt;li&gt;cameras&lt;/li&gt;
&lt;li&gt;sensors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because these services are event driven rather than compute heavy, they perform very well on Raspberry Pi hardware.&lt;/p&gt;
&lt;h4 id=&quot;4-local-api-services&quot;&gt;4. Local API Services&lt;/h4&gt;
&lt;p&gt;Developers often run small APIs for testing or internal tools.&lt;/p&gt;
&lt;p&gt;For example, you could host:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a Node.js API&lt;/li&gt;
&lt;li&gt;a Python Flask service&lt;/li&gt;
&lt;li&gt;a Laravel backend&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These APIs can be used for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;automation workflows&lt;/li&gt;
&lt;li&gt;IoT device communication&lt;/li&gt;
&lt;li&gt;experimental projects&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Your Raspberry Pi essentially becomes a small development server.&lt;/p&gt;
&lt;h4 id=&quot;5-network-utilities&quot;&gt;5. Network Utilities&lt;/h4&gt;
&lt;p&gt;The Raspberry Pi can also act as a network utility server.&lt;/p&gt;
&lt;p&gt;Common examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pi hole for network wide ad blocking&lt;/li&gt;
&lt;li&gt;local DNS servers&lt;/li&gt;
&lt;li&gt;VPN gateways&lt;/li&gt;
&lt;li&gt;SSH jump hosts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These services require very little processing power but provide significant value in a home or lab environment.&lt;/p&gt;
&lt;h3 id=&quot;using-docker-to-manage-raspberry-pi-services&quot;&gt;Using Docker to Manage Raspberry Pi Services&lt;/h3&gt;
&lt;p&gt;One of the best ways to run multiple services is by using &lt;strong&gt;Docker containers&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Docker allows you to isolate applications, manage dependencies, and deploy services quickly.&lt;/p&gt;
&lt;p&gt;Install Docker with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;curl -sSL https://get.docker.com | sh
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once installed, you can run services like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;docker run -d -p 3000:3000 my-service
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using Docker on Raspberry Pi also prepares you for modern DevOps workflows used in production environments.&lt;/p&gt;
&lt;h3 id=&quot;performance-tips-for-running-services-on-raspberry-pi&quot;&gt;Performance Tips for Running Services on Raspberry Pi&lt;/h3&gt;
&lt;p&gt;Although the Raspberry Pi is powerful for its size, optimizing performance is important.&lt;/p&gt;
&lt;h4 id=&quot;use-lightweight-applications&quot;&gt;Use Lightweight Applications&lt;/h4&gt;
&lt;p&gt;Avoid heavy services that require large databases or significant processing.&lt;/p&gt;
&lt;h4 id=&quot;monitor-resource-usage&quot;&gt;Monitor Resource Usage&lt;/h4&gt;
&lt;p&gt;Tools like &lt;code&gt;htop&lt;/code&gt; help you track CPU and memory usage in real time.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;htop
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;reduce-background-processes&quot;&gt;Reduce Background Processes&lt;/h4&gt;
&lt;p&gt;Running fewer unnecessary services keeps the system responsive.&lt;/p&gt;
&lt;h4 id=&quot;use-ssd-storage-if-possible-&quot;&gt;Use SSD Storage (If Possible)&lt;/h4&gt;
&lt;p&gt;An external SSD significantly improves read/write performance compared to microSD cards.&lt;/p&gt;
&lt;h3 id=&quot;security-best-practices&quot;&gt;Security Best Practices&lt;/h3&gt;
&lt;p&gt;Any device running services should follow basic security principles.&lt;/p&gt;
&lt;p&gt;Some simple steps include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Change the default password&lt;/li&gt;
&lt;li&gt;Disable unused ports&lt;/li&gt;
&lt;li&gt;Use SSH keys instead of passwords&lt;/li&gt;
&lt;li&gt;Enable automatic updates&lt;/li&gt;
&lt;li&gt;Install a firewall such as &lt;code&gt;ufw&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example firewall setup:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt install ufw
sudo ufw allow ssh
sudo ufw enable
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These small changes greatly improve security.&lt;/p&gt;
&lt;h3 id=&quot;why-developers-love-raspberry-pi-home-labs&quot;&gt;Why Developers Love Raspberry Pi Home Labs&lt;/h3&gt;
&lt;p&gt;Many engineers build entire &lt;strong&gt;home lab environments&lt;/strong&gt; using Raspberry Pi devices.&lt;/p&gt;
&lt;p&gt;These labs allow developers to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;test deployment pipelines&lt;/li&gt;
&lt;li&gt;experiment with Kubernetes or Docker&lt;/li&gt;
&lt;li&gt;simulate distributed systems&lt;/li&gt;
&lt;li&gt;learn networking and automation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s a practical way to gain real infrastructure experience without expensive cloud costs.&lt;/p&gt;
&lt;h2 id=&quot;final-thoughts-small-device-big-possibilities&quot;&gt;Final Thoughts: Small Device, Big Possibilities&lt;/h2&gt;
&lt;p&gt;The Raspberry Pi proves that powerful infrastructure doesn’t always require large servers or expensive cloud environments.&lt;/p&gt;
&lt;p&gt;With the right setup, this tiny computer can run &lt;strong&gt;reliable lightweight services&lt;/strong&gt; for development, monitoring, automation, and learning.&lt;/p&gt;
&lt;p&gt;Whether you're building a personal DevOps lab, hosting internal tools, or experimenting with IoT projects, the Raspberry Pi provides a flexible platform to explore and innovate.&lt;/p&gt;
&lt;p&gt;If you haven’t tried running services on one yet, now is the perfect time to start. You might be surprised how much you can accomplish with such a small device.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;If you found this guide useful, share it with fellow developers or anyone exploring Raspberry Pi projects. More practical tutorials and DevOps insights are coming soon.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/12517/running-lightweight-services-on-raspberry-pi-build-powerful-mini-servers-at-home</guid>
<pubDate>Tue, 10 Mar 2026 13:20:18 +0000</pubDate>
</item>
<item>
<title>Securing Your VPS: Basic Firewall, SSH, and SSL Setup Guide</title>
<link>https://coderlegion.com/3268/securing-your-vps-basic-firewall-ssh-and-ssl-setup-guide</link>
<description>&lt;div class=&quot;div-green&quot;&gt;
&lt;span class=&quot;alert-body&quot;&gt;A Simple Guide to Make Your VPS Safer — Even If You're Just Starting Out&lt;/span&gt;
&lt;/div&gt;
&lt;p&gt;Your &lt;strong&gt;VPS (Virtual Private Server)&lt;/strong&gt; is like your home on the internet — and just like a home, it needs locks, fences, and security cameras to stay safe. This guide will walk you through &lt;strong&gt;three critical steps&lt;/strong&gt; to secure your VPS:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set up a basic firewall&lt;/li&gt;
&lt;li&gt;Secure -SSH access&lt;/li&gt;
&lt;li&gt;Install SSL for HTTPS&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;step-1-set-up-a-basic-firewall-with-ufw-uncomplicated-firewall-&quot;&gt;Step 1: Set Up a Basic Firewall with UFW (Uncomplicated Firewall)&lt;/h3&gt;
&lt;p&gt;A firewall controls what kind of traffic can reach your VPS. Let’s use &lt;strong&gt;UFW&lt;/strong&gt;, a beginner-friendly firewall for Ubuntu/Debian systems.&lt;/p&gt;
&lt;h4 id=&quot;-install-ufw&quot;&gt;✅ Install UFW&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt update
sudo apt install ufw
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-allow-ssh-so-you-don-t-lock-yourself-out-&quot;&gt;✅ Allow SSH (so you don’t lock yourself out)&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw allow OpenSSH
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you're using a non-standard SSH port (e.g., 2222), allow that too:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw allow 2222/tcp
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-allow-http-and-https&quot;&gt;✅ Allow HTTP and HTTPS&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw allow 80
sudo ufw allow 443
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-enable-the-firewall&quot;&gt;✅ Enable the Firewall&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw enable
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To check status:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo ufw status
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;div-red&quot;&gt;
&lt;span class=&quot;alert-header&quot;&gt;Pro Tip:&lt;/span&gt;
&lt;span class=&quot;alert-body&quot;&gt;Only open ports that your app or server needs!&lt;/span&gt;
&lt;/div&gt;
&lt;hr&gt;
&lt;h3 id=&quot;step-2-secure-ssh-access&quot;&gt;Step 2: Secure SSH Access&lt;/h3&gt;
&lt;p&gt;SSH is how you remotely access your server. But by default, it’s a bit too open.&lt;/p&gt;
&lt;h4 id=&quot;-change-the-default-ssh-port-optional-but-adds-extra-protection-&quot;&gt;✅ Change the Default SSH Port (optional but adds extra protection)&lt;/h4&gt;
&lt;p&gt;Edit the SSH config file:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo nano /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Find and change:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;Port 22
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To something like:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;Port 2222
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then restart SSH:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-disable-root-login-via-ssh&quot;&gt;✅ Disable Root Login via SSH&lt;/h4&gt;
&lt;p&gt;Still in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;, find:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;PermitRootLogin yes
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change to:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;PermitRootLogin no
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart SSH again:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-use-ssh-keys-instead-of-passwords&quot;&gt;✅ Use SSH Keys Instead of Passwords&lt;/h4&gt;
&lt;p&gt;From your &lt;strong&gt;local machine&lt;/strong&gt;, run:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ssh-keygen -t rsa -b 4096
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then copy the key to your VPS:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ssh-copy-id username@your-server-ip
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Disable password authentication (optional but recommended):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo nano /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;PasswordAuthentication no
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart SSH:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo systemctl restart ssh
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;step-3-install-free-ssl-using-let-s-encrypt-with-certbot-&quot;&gt;Step 3: Install Free SSL Using Let’s Encrypt (with Certbot)&lt;/h3&gt;
&lt;p&gt;SSL (HTTPS) encrypts your website traffic. Let’s Encrypt makes it easy and free.&lt;/p&gt;
&lt;h4 id=&quot;-install-certbot&quot;&gt;✅ Install Certbot&lt;/h4&gt;
&lt;p&gt;For Nginx:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt install certbot python3-certbot-nginx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For Apache:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt install certbot python3-certbot-apache
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;-issue-an-ssl-certificate&quot;&gt;✅ Issue an SSL Certificate&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo certbot --nginx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or for Apache:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo certbot --apache
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Follow the prompt and choose to redirect HTTP to HTTPS.&lt;/p&gt;
&lt;h4 id=&quot;-auto-renew-ssl&quot;&gt;✅ Auto-Renew SSL&lt;/h4&gt;
&lt;p&gt;Let’s Encrypt certificates expire every 90 days. Set up auto-renewal:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo systemctl list-timers
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Certbot typically installs a timer, but you can test renewal with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo certbot renew --dry-run
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;
&lt;div class=&quot;div-blue&quot;&gt;
&lt;span class=&quot;alert-body&quot;&gt;Security doesn't have to be scary.&lt;/span&gt;
&lt;/div&gt;
&lt;p&gt;With just a few commands, you've:&lt;/p&gt;
&lt;p&gt;✅ Protected your SSH login&lt;br&gt;
✅ Closed unnecessary network doors&lt;br&gt;
✅ Encrypted web traffic with HTTPS&lt;/p&gt;
&lt;p&gt;These are &lt;strong&gt;must-do steps&lt;/strong&gt; for anyone hosting websites, APIs, or apps on a VPS — even beginners.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;bonus-tools-for-extra-security-optional-&quot;&gt;Bonus Tools for Extra Security (Optional)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fail2Ban&lt;/strong&gt;: Automatically blocks brute-force attempts&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ModSecurity&lt;/strong&gt;: Web application firewall&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Auditd&lt;/strong&gt;: For logging and monitoring server changes&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&quot;resources&quot;&gt;Resources&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://help.ubuntu.com/community/UFW&quot;&gt;UFW Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.ssh.com/academy/ssh/security-best-practices&quot;&gt;SSH Hardening Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://letsencrypt.org&quot;&gt;Let’s Encrypt&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Basic Commands</category>
<guid isPermaLink="true">https://coderlegion.com/3268/securing-your-vps-basic-firewall-ssh-and-ssl-setup-guide</guid>
<pubDate>Sat, 07 Jun 2025 17:01:23 +0000</pubDate>
</item>
<item>
<title>Understanding Linux Package Manager: Deploying A Lamp Stack in Linux.</title>
<link>https://coderlegion.com/1706/understanding-linux-package-manager-deploying-a-lamp-stack-in-linux</link>
<description>&lt;p&gt;A package manager in Linux is a command-line or graphical tool that automates the process of installing, updating, configuring, and removing software packages. It simplifies software management by handling dependencies, repositories, and system consistency.&lt;/p&gt;
&lt;h3 id=&quot;key-functions-of-a-package-manager-&quot;&gt;Key Functions of a Package Manager:&lt;/h3&gt;
&lt;p&gt;Installation: Downloads and installs software packages from a repository.&lt;br&gt;
Upgrades: Updates software packages to the latest versions.&lt;br&gt;
Removal: Removes software packages from the system.&lt;br&gt;
Dependency Management: Automatically resolves and installs any required dependencies for a package.&lt;br&gt;
Package Integrity: Verifies the authenticity and integrity of packages.&lt;br&gt;
Repository Management: Allows users to add or remove software repositories.&lt;/p&gt;
&lt;h3 id=&quot;why-are-package-managers-important-&quot;&gt;Why are Package Managers Important?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Simplified Software Management:&lt;/strong&gt;&lt;br&gt;
They automate the process of installing, updating, and removing software, making it easier for users to manage their systems. &lt;br&gt;
&lt;strong&gt;Dependency Resolution:&lt;/strong&gt;&lt;br&gt;
They automatically handle dependencies, ensuring that all required packages are installed, which prevents &quot;dependency hell&quot;. &lt;br&gt;
&lt;strong&gt;Security and Integrity:&lt;/strong&gt;&lt;br&gt;
They help ensure that software packages are authentic and haven't been tampered with. &lt;br&gt;
&lt;strong&gt;Centralized Repositories:&lt;/strong&gt;&lt;br&gt;
They allow users to access a centralized repository of software packages, making it easier to find and install software. &lt;/p&gt;
&lt;h3 id=&quot;example-workflow-ubuntu-&quot;&gt;Example Workflow (Ubuntu):&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34fiasg8ieomy7xs76iv.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;Without wasting much time, let us begin by downloading Ubuntu's package manager. To do this, you need to download Ubuntu Multipass. After downloading and installing it successful , here is how it will look once you open the Multipass;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/up69hu5daqevbb0l7bzi.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;You will need to download an Ubuntu image.After the downloaded the image, open the instance on the left hand pane of the multipass app. Click on new terminal.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/imt77ag7m9eb4ynth90w.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;Once you open the shell a welcome note will appear, to clear that welcome note you will need to run the command &lt;strong&gt;&quot;clear&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5umn0hfb1ftysznvupd6.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;To install anything in Ubuntu, you need to be on admin mode. The command for that is &lt;strong&gt;&quot;Sudo Su&quot;&lt;/strong&gt;. Now if you do not want to be on admin mode (root mode)but still want to perform an installation, lets say you want to install NGINX, &lt;strong&gt;&quot;Sudo apt install nginx&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqd73cqmjbjbeqeq77lw.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;note-&quot;&gt;NOTE:&lt;/h3&gt;
&lt;p&gt;Provided you're not in root mode, you will need to add &lt;strong&gt;&quot;Sudo&quot;&lt;/strong&gt; to every command. Sudo gives you that administrative privilege.&lt;/p&gt;
&lt;h3 id=&quot;deploying-a-lamp-stack&quot;&gt;DEPLOYING A LAMP STACK&lt;/h3&gt;
&lt;p&gt;The LAMP stack is a robust, open-source software suite used to build and host dynamic websites and web applications. A LAMP stack is a popular open-source software bundle used for building and hosting web applications. The acronym &quot;LAMP&quot; stands for the four core components: Linux, Apache, MySQL and PHP.&lt;/p&gt;
&lt;h3 id=&quot;here-s-a-breakdown-of-each-component-&quot;&gt;&lt;em&gt;Here's a breakdown of each component:&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;br&gt;
The open-source operating system that serves as the foundation for the LAMP stack, providing a stable and secure environment for running web applications. &lt;br&gt;
&lt;strong&gt;Apache:&lt;/strong&gt;&lt;br&gt;
A widely used web server software that handles HTTP requests and delivers web content to users. &lt;br&gt;
&lt;strong&gt;MySQL:&lt;/strong&gt;&lt;br&gt;
A relational database management system used for storing and managing data for web applications. &lt;br&gt;
&lt;strong&gt;PHP:&lt;/strong&gt;&lt;br&gt;
A server-side scripting language used to create dynamic web content, interacting with MySQL to fetch and display data. &lt;/p&gt;
&lt;h3 id=&quot;step-by-step-deployment&quot;&gt;Step-by-Step Deployment&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Step 1: System Update&lt;/strong&gt;&lt;br&gt;
To do this, run the command &lt;strong&gt;&quot;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eg732xss9trf8v159o4y.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Install Apache Web Server&lt;/strong&gt;&lt;br&gt;
To install apache2, run the command &lt;strong&gt;&quot;sudo apt install apache2 -y&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crvp9yypv5rslwkzt19t.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Enable and start the service&lt;/strong&gt;&lt;br&gt;
Run the command &lt;strong&gt;&quot;sudo systemctl enable apache2 --now&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8utk1km08wgdodc24wu4.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;To know if Apache2 is installed, run the command &quot;ip addr show.&quot;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atkut0ft3qlwwoprsd68.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;Copy the IP address and paste on a browser.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4: Install MySQL Database&lt;/strong&gt;&lt;br&gt;
Run the command  &lt;strong&gt;&quot;sudo apt install mysql-server -y&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ru5q0bwfxi372kcswihi.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5: Secure MySQL&lt;/strong&gt; &lt;br&gt;
Run the command &quot;sudo mysql_secure_installation&quot;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5iljlqqxz0agb5ov17fq.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 6: Install PHP&lt;/strong&gt;&lt;br&gt;
Run the command &lt;strong&gt;&quot;sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-json -y&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wf1bs10aeaivbgrtrw1.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 7: Test PHP Configuration&lt;/strong&gt;&lt;br&gt;
Run the command  &lt;strong&gt;echo &quot;&amp;lt;?php phpinfo(); ?&amp;gt;&quot; | sudo tee /var/www/html/info.php&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11s2jddxptku7o2dnsw1.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;Visit: http:// your IP address/info.php to view the PHP details page.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fmghjdechuk9i9a26bt.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 8: Remove the test file afterward&lt;/strong&gt;&lt;br&gt;
Run the command &lt;strong&gt;sudo rm /var/www/html/info.php&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptnuc6edv1eao3x3h3ll.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 9: Security Best Practices&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Configure Firewall&lt;br&gt;
Allow only necessary traffic:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Allow HTTP/HTTPS&lt;br&gt;
Run the command sudo ufw allow 'Apache Full'&lt;/li&gt;
&lt;li&gt;Allow SSH&lt;br&gt;
Run the cammand &quot;sudo ufw allow ssh&quot;&lt;/li&gt;
&lt;li&gt;Activate firewall&lt;br&gt;
Run the command &quot;sudo ufw enable&quot;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2j2uzpahayuud3b18oz.png&quot; alt=&quot;Image description&quot;&gt;&lt;/p&gt;
&lt;p&gt;We have successfully deployed a LAMP Stack on Linux for hosting dynamic websites and web applications. That wasn't difficult.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/1706/understanding-linux-package-manager-deploying-a-lamp-stack-in-linux</guid>
<pubDate>Sun, 30 Mar 2025 08:31:27 +0000</pubDate>
</item>
<item>
<title>Setup a LAMP Server on a VPS in Under an Hour: The Ultimate Guide to Web Hosting</title>
<link>https://coderlegion.com/1157/setup-a-lamp-server-on-a-vps-in-under-an-hour-the-ultimate-guide-to-web-hosting</link>
<description>

  &lt;p&gt;In today’s digital age, having a reliable web hosting solution is paramount. A Virtual Private Server (VPS) offers a balance of affordability, performance, and full control over your server environment. This guide will walk you through setting up a robust LAMP (Linux, Apache, MariaDB, PHP) stack on your VPS using an automated Bash script—all in under an hour.&lt;/p&gt;
  
  &lt;p&gt;For the complete installation script and further details, please visit our GitHub repository: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/giftbalogun/vpsLAMPsetup&quot; target=&quot;_blank&quot;&gt;https://github.com/giftbalogun/vpsLAMPsetup&lt;/a&gt;.&lt;/p&gt;
  
  &lt;h2&gt;Why Choose a VPS for Web Hosting?&lt;/h2&gt;
  &lt;p&gt;A VPS offers dedicated resources and increased flexibility compared to shared hosting. This means better performance, enhanced security, and complete control over the software and configurations installed on your server. Whether you’re hosting a personal blog or a complex web application, a VPS is an excellent choice.&lt;/p&gt;
  
  &lt;h2&gt;Understanding the LAMP Stack&lt;/h2&gt;
  &lt;p&gt;The LAMP stack is a proven combination of technologies that work together to create a powerful web hosting environment:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;Linux&lt;/strong&gt; - The operating system that serves as the foundation.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;Apache&lt;/strong&gt; - A popular and reliable web server for handling HTTP requests.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;MariaDB&lt;/strong&gt; - A robust database management system (a fork of MySQL) used to store and manage data.&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;PHP&lt;/strong&gt; - A server-side scripting language that enables dynamic web content.&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;h2&gt;Step-by-Step Setup Guide&lt;/h2&gt;
  
  &lt;h3&gt;1. Updating the System&lt;/h3&gt;
  &lt;p&gt;Before installing any packages, it’s important to update your system to ensure all repositories and packages are current. This minimizes conflicts and security vulnerabilities.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo apt update -y
sudo apt upgrade -y&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;The setup script automatically performs these steps. In case of an error, the script is designed to cancel the installation gracefully.&lt;/p&gt;
  
  &lt;h3&gt;2. Installing Apache Web Server&lt;/h3&gt;
  &lt;p&gt;Apache is the core component of our LAMP stack. The script installs Apache, starts the service immediately, and enables it to run on boot, ensuring your web server is always operational.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;These commands ensure that Apache is installed correctly and persists across reboots.&lt;/p&gt;
  
  &lt;h3&gt;3. Installing PHP and Essential Extensions&lt;/h3&gt;
  &lt;p&gt;PHP powers dynamic web content. The script installs PHP along with a suite of extensions needed to support various functionalities such as database connectivity, JSON processing, and more.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo apt install php libapache2-mod-php php-cli php-common php-redis php-mysql php-cgi php-curl php-json php-mbstring php-xml php-zip php-pdo php-phar php-iconv -y&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;Each extension is chosen to provide comprehensive support for modern web applications.&lt;/p&gt;
  
  &lt;h3&gt;4. Installing MariaDB&lt;/h3&gt;
  &lt;p&gt;MariaDB serves as our database system. It’s known for its speed and reliability, making it a great alternative to MySQL. The script installs MariaDB, starts it, and configures it to launch on startup.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb&lt;/code&gt;&lt;/pre&gt;
  
  &lt;h3&gt;5. Securing Your Database&lt;/h3&gt;
  &lt;p&gt;Security is critical when managing databases. The script runs &lt;code&gt;mysql_secure_installation&lt;/code&gt; to help you set a root password, remove anonymous users, and disable remote root logins. This hardening process is essential to protect your data.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo mysql_secure_installation&lt;/code&gt;&lt;/pre&gt;
  
  &lt;h3&gt;6. Installing phpMyAdmin&lt;/h3&gt;
  &lt;p&gt;phpMyAdmin provides a web-based interface for managing your MariaDB databases. The script installs phpMyAdmin and creates a symbolic link in Apache’s root directory, making it easily accessible through your browser.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo apt install phpmyadmin -y
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;After installation, you can access phpMyAdmin at &lt;code&gt;http://your-server-ip/phpmyadmin&lt;/code&gt;.&lt;/p&gt;
  
  &lt;h3&gt;7. Restarting Apache&lt;/h3&gt;
  &lt;p&gt;To apply all configuration changes and updates, the script restarts Apache. This ensures that all new installations and settings take effect immediately.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;sudo systemctl restart apache2&lt;/code&gt;&lt;/pre&gt;
  
  &lt;h3&gt;8. Installing Composer&lt;/h3&gt;
  &lt;p&gt;Composer is a dependency manager for PHP that simplifies the management of libraries and packages. The script downloads Composer and moves it to a system-wide accessible location.&lt;/p&gt;
  &lt;pre&gt;&lt;code&gt;curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version&lt;/code&gt;&lt;/pre&gt;
  &lt;p&gt;This ensures that Composer is installed correctly and can be used for managing your PHP project dependencies.&lt;/p&gt;
  
  &lt;h2&gt;The Complete Automated Installation Script&lt;/h2&gt;
  &lt;p&gt;The following Bash script encapsulates all the steps mentioned above. It includes error handling to ensure that if any step fails, the installation process is halted and the system remains in a stable state.&lt;/p&gt;

  &lt;pre&gt;
&lt;code&gt;

#!/bin/bash

# Function to handle cancellation
cancel_installation() {
  echo -e &quot;\nInstallation canceled by the user. Cleaning up...&quot;
  exit 1
}

# Set trap for SIGINT (Ctrl+C)
trap cancel_installation SIGINT

# Update package list
echo &quot;Updating package list...&quot;
sudo apt update -y || cancel_installation
sudo apt upgrade -y || cancel_installation

# Install Apache
echo &quot;Installing Apache...&quot;
if ! sudo apt install apache2 -y; then
  echo &quot;Failed to install Apache. Exiting...&quot;
  exit 1
fi
sudo systemctl start apache2 || cancel_installation
sudo systemctl enable apache2 || cancel_installation

# Install PHP and necessary extensions
echo &quot;Installing PHP and required extensions...&quot;
if ! sudo apt install php libapache2-mod-php php-cli php-common php-redis php-mysql php-cgi php-curl php-json php-mbstring php-xml php-zip php-pdo php-phar php-iconv -y; then
  echo &quot;Failed to install PHP. Exiting...&quot;
  exit 1
fi

# Install MariaDB
echo &quot;Installing MariaDB...&quot;
if ! sudo apt install mariadb-server -y; then
  echo &quot;Failed to install MariaDB. Exiting...&quot;
  exit 1
fi
sudo systemctl start mariadb || cancel_installation
sudo systemctl enable mariadb || cancel_installation

# Secure MariaDB installation
echo &quot;Securing MariaDB...&quot;
sudo mysql_secure_installation || cancel_installation

# Install phpMyAdmin
echo &quot;Installing phpMyAdmin...&quot;
if ! sudo apt install phpmyadmin -y; then
  echo &quot;Failed to install phpMyAdmin. Exiting...&quot;
  exit 1
fi

# Enable phpMyAdmin in Apache
echo &quot;Enabling phpMyAdmin in Apache...&quot;
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin || cancel_installation

# Restart Apache
echo &quot;Restarting Apache...&quot;
sudo systemctl restart apache2 || cancel_installation

# Install Composer
echo &quot;Installing Composer...&quot;
if ! curl -sS https://getcomposer.org/installer | php; then
  echo &quot;Failed to download Composer. Exiting...&quot;
  exit 1
fi
sudo mv composer.phar /usr/local/bin/composer
composer --version || cancel_installation

# Final Summary
echo &quot;Installation complete!&quot;
echo &quot;---------------------------------------------------------&quot;
echo &quot;Apache is installed and running.&quot;
echo &quot;PHP and necessary extensions are installed.&quot;
echo &quot;MariaDB is installed and running.&quot;
echo &quot;phpMyAdmin is accessible at http://$(hostname -I | awk '{print $1}')/phpmyadmin&quot;
echo &quot;Composer is installed and ready to use.&quot;
echo &quot;---------------------------------------------------------&quot;

&lt;/code&gt;&lt;/pre&gt;

  
&lt;p&gt;This script ensures that each step is executed correctly, and that the system is left in a stable state even if errors occur. By automating the installation process, you can deploy a fully functional LAMP server quickly and with confidence.&lt;/p&gt;
  
  &lt;h2&gt;Wrapping Up&lt;/h2&gt;
  &lt;p&gt;With your LAMP server now set up on your VPS, you have a robust environment ready for hosting websites, web applications, or even development projects. The flexibility of a VPS combined with the reliability of the LAMP stack makes this an ideal solution for many use cases.&lt;/p&gt;
  &lt;p&gt;Remember to keep your server updated and secure by routinely applying patches and monitoring its performance. With tools like phpMyAdmin and Composer at your disposal, managing your server and deploying applications becomes a streamlined process.&lt;/p&gt;
  
  &lt;h2&gt;Conclusion&lt;/h2&gt;
  &lt;p&gt;This guide has walked you through setting up a LAMP server on a VPS in under an hour. The key takeaways include:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Using a VPS for greater control, performance, and security.&lt;/li&gt;
    &lt;li&gt;The benefits of the LAMP stack for robust web hosting.&lt;/li&gt;
    &lt;li&gt;Automating server setup with a comprehensive Bash script.&lt;/li&gt;
    &lt;li&gt;Ensuring secure database management and easy PHP dependency management with Composer.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;p&gt;For the full installation script and more details, be sure to visit our GitHub repository: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/giftbalogun/vpsLAMPsetup&quot; target=&quot;_blank&quot;&gt;https://github.com/giftbalogun/vpsLAMPsetup&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;Happy Hosting! &lt;/strong&gt;&lt;/p&gt;


</description>
<category>Apache Web Hosting</category>
<guid isPermaLink="true">https://coderlegion.com/1157/setup-a-lamp-server-on-a-vps-in-under-an-hour-the-ultimate-guide-to-web-hosting</guid>
<pubDate>Wed, 19 Feb 2025 14:48:22 +0000</pubDate>
</item>
</channel>
</rss>