<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nginx &#8211; Aveshost Blog</title>
	<atom:link href="https://blog.aveshost.com/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.aveshost.com</link>
	<description>Your Blueprint for Online Success</description>
	<lastBuildDate>Thu, 19 Nov 2026 18:40:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://blog.aveshost.com/wp-content/uploads/2026/01/logo-150x150.png</url>
	<title>Nginx &#8211; Aveshost Blog</title>
	<link>https://blog.aveshost.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Deploy FastAPI on an Ubuntu VPS with Nginx and HTTPS</title>
		<link>https://blog.aveshost.com/deploy-fastapi-ubuntu-vps/</link>
					<comments>https://blog.aveshost.com/deploy-fastapi-ubuntu-vps/#respond</comments>
		
		<dc:creator><![CDATA[James Wilson]]></dc:creator>
		<pubDate>Thu, 19 Nov 2026 18:40:00 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[FastAPI]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Linux VPS]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=6020</guid>

					<description><![CDATA[Run FastAPI privately behind Nginx, keep it online with systemd, enable HTTPS with Certbot and verify the deployment from application to certificate renewal.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">To <strong>deploy FastAPI</strong> on an Ubuntu VPS, run the application with Uvicorn on <code>127.0.0.1:8000</code>, supervise it with systemd, and put Nginx in front on ports 80 and 443. Nginx terminates HTTPS while the application remains reachable only through the local upstream.</p>



<p class="wp-block-paragraph">Our walkthrough takes a small API from a Python virtual environment to a working domain with a renewable certificate. It uses a dedicated service account and includes checks at each layer, so you can identify a failed application, proxy configuration or certificate challenge separately.</p>



<p class="wp-block-paragraph">Use a fresh Ubuntu 24.04 LTS VPS, SSH access with sudo privileges, and a domain or subdomain you control. Replace <code>api.example.com</code> throughout with your real hostname. This example serves a standard HTTP API at the domain root; it does not configure Docker, WebSockets, streaming, a database or a control-panel-managed Nginx installation.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#prepare">1. Prepare the VPS, DNS and firewall</a></div><div><a href="#app">2. Create the application and virtual environment</a></div><div><a href="#systemd">3. Keep FastAPI running with systemd</a></div><div><a href="#nginx">4. Put Nginx in front of FastAPI</a></div><div><a href="#https">5. Enable HTTPS with Certbot</a></div><div><a href="#renewal">6. Verify renewal and external access</a></div><div><a href="#troubleshoot">7. Troubleshoot the failing layer</a></div><div><a href="#maintain">8. Deploy FastAPI updates and plan capacity</a></div><div><a href="#faq">Frequently asked questions</a></div></div></nav></div>



<h2 id="prepare" class="wp-block-heading">1. Prepare the VPS, DNS and firewall</h2>



<p class="wp-block-paragraph">Point the hostname’s A record to the VPS IPv4 address. Add an AAAA record only when IPv6 reaches this same server correctly. Keep an existing SSH connection open and confirm console recovery access before changing firewall policy.</p>



<p class="wp-block-paragraph">Install the packages used below:</p>



<pre class="wp-block-code"><code>sudo apt update
sudo apt install -y python3-venv nginx curl dnsutils ufw snapd
dig +short A api.example.com
dig +short AAAA api.example.com</code></pre>



<p class="wp-block-paragraph">For a new server using SSH on port 22, allow SSH and the web-server ports before enabling UFW:</p>



<pre class="wp-block-code"><code>sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status verbose</code></pre>



<p class="wp-block-paragraph">If SSH uses another port, allow that actual TCP port first. Preserve existing rules on a server already in use. Apply equivalent access rules to any upstream VPS firewall. Do not open port 8000 publicly. Ubuntu’s <a href="https://ubuntu.com/server/docs/how-to/security/firewalls/" rel="noopener">firewall guide</a> explains UFW, and its <a href="https://ubuntu.com/server/docs/how-to/web-services/install-nginx/" rel="noopener">Nginx guide</a> covers the Ubuntu package layout.</p>



<p class="wp-block-paragraph">For this HTTP-01 certificate workflow, the hostname must be publicly reachable on port 80. Incorrect DNS, including a stale AAAA record, can prevent validation. See <a href="https://letsencrypt.org/docs/challenge-types/" rel="noopener">Let’s Encrypt’s challenge requirements</a>.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1536" height="1024" src="https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-nginx-https-architecture.webp" alt="FastAPI deployment architecture showing Nginx handling HTTPS, localhost Uvicorn, systemd supervision and Certbot renewal." class="wp-image-6022" srcset="https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-nginx-https-architecture.webp 1536w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-nginx-https-architecture-300x200.webp 300w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-nginx-https-architecture-1024x683.webp 1024w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-nginx-https-architecture-768x512.webp 768w" sizes="(max-width: 1536px) 100vw, 1536px" /></figure>



<h2 id="app" class="wp-block-heading">2. Create the application and virtual environment</h2>



<p class="wp-block-paragraph">Create a dedicated system account and project directory. These commands are for a new installation; choose different names if they already exist:</p>



<pre class="wp-block-code"><code>sudo adduser --system --group --home /opt/fastapi fastapi
sudo install -d -o fastapi -g fastapi -m 0755 /opt/fastapi
sudo -u fastapi python3 -m venv /opt/fastapi/.venv
sudo -u fastapi /opt/fastapi/.venv/bin/python -m pip install fastapi uvicorn</code></pre>



<p class="wp-block-paragraph">The <a href="https://docs.python.org/3/library/venv.html" rel="noopener">Python virtual environment</a> keeps application packages separate from Ubuntu’s system Python. For an existing project, install its reviewed, pinned requirements instead of replacing them with this demonstration’s dependencies.</p>



<p class="wp-block-paragraph">Create <code>/opt/fastapi/main.py</code> with <code>sudo nano /opt/fastapi/main.py</code>, paste the following and save:</p>



<pre class="wp-block-code"><code>from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "FastAPI is running"}

@app.get("/health")
async def health():
    return {"status": "ok"}
</code></pre>



<p class="wp-block-paragraph">Run the ASGI server in the foreground:</p>



<pre class="wp-block-code"><code>sudo -u fastapi /opt/fastapi/.venv/bin/uvicorn main:app --app-dir /opt/fastapi --host 127.0.0.1 --port 8000</code></pre>



<p class="wp-block-paragraph">In a second SSH session, run <code>curl -fsS http://127.0.0.1:8000/health</code>. Expect <code>{"status":"ok"}</code>. Stop the foreground server with Ctrl+C before starting systemd, freeing port 8000. FastAPI’s <a href="https://fastapi.tiangolo.com/deployment/manually/" rel="noopener">server documentation</a> explains the application import string.</p>



<h2 id="systemd" class="wp-block-heading">3. Keep FastAPI running with systemd</h2>



<p class="wp-block-paragraph">Create an empty environment file for application settings, readable by root and the service group:</p>



<pre class="wp-block-code"><code>sudo install -o root -g fastapi -m 0640 /dev/null /etc/fastapi.env</code></pre>



<p class="wp-block-paragraph">Later, add required <code>NAME=value</code> settings using <code>sudoedit /etc/fastapi.env</code>. The app must explicitly read those settings; creating the file does not configure a database automatically. Keep credentials out of source control and logs.</p>



<p class="wp-block-paragraph">Create <code>/etc/systemd/system/fastapi.service</code> with <code>sudo nano /etc/systemd/system/fastapi.service</code> and save:</p>



<pre class="wp-block-code"><code>&#91;Unit]
Description=FastAPI application
After=network.target

&#91;Service]
User=fastapi
Group=fastapi
WorkingDirectory=/opt/fastapi
EnvironmentFile=/etc/fastapi.env
ExecStart=/opt/fastapi/.venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --workers 1 --proxy-headers --forwarded-allow-ips=127.0.0.1
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true

&#91;Install]
WantedBy=multi-user.target
</code></pre>



<p class="wp-block-paragraph">The absolute executable path removes the need to activate the virtual environment. <code>WorkingDirectory</code> lets Uvicorn import <code>main:app</code>. The service runs as the dedicated account and restarts after failure; repeated failures can still hit systemd’s start-rate limits.</p>



<pre class="wp-block-code"><code>sudo systemctl daemon-reload
sudo systemctl enable --now fastapi
sudo systemctl status fastapi --no-pager
curl -fsS http://127.0.0.1:8000/health</code></pre>



<p class="wp-block-paragraph">If it fails, inspect <code>sudo journalctl -u fastapi -n 100 --no-pager</code>. See the <a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html" rel="noopener">systemd service reference</a> for supervision and the <a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html" rel="noopener">execution reference</a> for users, directories and environment files.</p>



<h2 id="nginx" class="wp-block-heading">4. Put Nginx in front of FastAPI</h2>



<p class="wp-block-paragraph">Create <code>/etc/nginx/sites-available/fastapi</code> with <code>sudo nano /etc/nginx/sites-available/fastapi</code>. Use this HTTP configuration first:</p>



<pre class="wp-block-code"><code>server {
    listen 80;
    listen &#91;::]:80;
    server_name api.example.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
</code></pre>



<p class="wp-block-paragraph">Enable the site, test syntax, then start or reload Nginx:</p>



<pre class="wp-block-code"><code>sudo ln -s /etc/nginx/sites-available/fastapi /etc/nginx/sites-enabled/fastapi
sudo nginx -t
sudo systemctl enable --now nginx
sudo systemctl reload nginx
curl -fsS http://api.example.com/health</code></pre>



<p class="wp-block-paragraph">Create the symlink only once. On a server hosting other sites, preserve their files and avoid duplicate <code>server_name</code> entries. If IPv6 is disabled at the OS level, omit the IPv6 listen directive rather than publishing a broken AAAA record.</p>



<p class="wp-block-paragraph">The <a href="https://nginx.org/en/docs/http/ngx_http_proxy_module.html" rel="noopener">Nginx proxy module</a> forwards requests to Uvicorn. This single-edge-proxy example overwrites incoming forwarded headers with values from Nginx’s connection; a CDN or additional load balancer requires a separate trusted-proxy design.</p>



<p class="wp-block-paragraph">Uvicorn trusts proxy headers only from <code>127.0.0.1</code> in our service command. Once HTTPS is enabled, that lets FastAPI build correct HTTPS redirects. Avoid trusting every source with a wildcard. FastAPI’s <a href="https://fastapi.tiangolo.com/advanced/behind-a-proxy/" rel="noopener">proxy guide</a> explains the trust boundary.</p>



<h2 id="https" class="wp-block-heading">5. Enable HTTPS with Certbot</h2>



<p class="wp-block-paragraph">Confirm the public HTTP hostname returns the health response before requesting a certificate. The endpoint is a harmless demonstration; do not send credentials or sensitive data over HTTP.</p>



<p class="wp-block-paragraph">This fresh-server workflow uses Certbot’s snap installation. If Certbot already exists through apt or another method, follow its migration instructions instead of mixing installations. Install the snap, then use its explicit executable path:</p>



<pre class="wp-block-code"><code>sudo snap install --classic certbot
sudo /snap/bin/certbot --nginx --redirect -d api.example.com</code></pre>



<p class="wp-block-paragraph">Follow the prompts for an account email and the certificate authority’s terms. Certbot’s Nginx plugin obtains the certificate and updates the selected site to serve HTTPS and redirect HTTP. Back up an existing Nginx configuration before letting it edit that configuration.</p>



<p class="wp-block-paragraph">Check the result without bypassing certificate verification:</p>



<pre class="wp-block-code"><code>sudo nginx -t
curl -fsS https://api.example.com/health
curl -fsS https://api.example.com/openapi.json</code></pre>



<p class="wp-block-paragraph">Visit <code>https://api.example.com/docs</code> and confirm the API documentation loads. HTTPS encrypts transport; it does not authenticate your API’s users. Add the access controls your real endpoints need. The <a href="https://certbot.eff.org/instructions?ws=nginx&amp;os=snap&amp;tab=standard" rel="noopener">official Certbot instructions</a> cover installation and issuance.</p>



<h2 id="renewal" class="wp-block-heading">6. Verify renewal and external access</h2>



<p class="wp-block-paragraph">Test automatic renewal and inspect the scheduled jobs:</p>



<pre class="wp-block-code"><code>sudo /snap/bin/certbot renew --dry-run
systemctl list-timers --all
sudo ss -ltnp</code></pre>



<p class="wp-block-paragraph">Confirm the Certbot renewal timer is present and scheduled. A successful initial certificate does not prove future renewal will work. Keep the required challenge route reachable and monitor expiry independently.</p>



<p class="wp-block-paragraph">In the listening-socket output, Uvicorn should use <code>127.0.0.1:8000</code>; Nginx should own the public web listeners. From a workstation outside the VPS, check HTTPS by hostname and verify that port 8000 is unreachable. Test IPv6 separately if the hostname has an AAAA record.</p>



<p class="wp-block-paragraph">Make a normal API request after a planned reboot and confirm <code>systemctl is-active fastapi nginx</code> reports both services active. The demo health route checks only the process’s HTTP response. For a database-backed app, design readiness checks that also validate critical dependencies without exposing secrets.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1536" height="1024" src="https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-deployment-checks.webp" alt="Four FastAPI deployment checks covering application health, systemd, Nginx configuration and HTTPS certificate renewal." class="wp-image-6023" srcset="https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-deployment-checks.webp 1536w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-deployment-checks-300x200.webp 300w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-deployment-checks-1024x683.webp 1024w, https://blog.aveshost.com/wp-content/uploads/2026/11/fastapi-deployment-checks-768x512.webp 768w" sizes="(max-width: 1536px) 100vw, 1536px" /></figure>



<h2 id="troubleshoot" class="wp-block-heading">7. Troubleshoot the failing layer</h2>



<p class="wp-block-paragraph">Diagnose from the application outward. If localhost is failing, changing DNS or requesting another certificate will not repair the Python process.</p>



<p class="wp-block-paragraph">Useful logs are <code>sudo journalctl -u fastapi -n 100 --no-pager</code> and <code>sudo tail -n 100 /var/log/nginx/error.log</code>. Redact tokens, cookies and personal data before sharing them. Avoid repeatedly retrying certificate issuance while DNS or network access is still broken.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Symptom</th><th>Check first</th><th>Likely action</th></tr></thead><tbody><tr><td>502 Bad Gateway</td><td>Local health URL and service logs</td><td>Fix import, dependency, process or upstream port</td></tr><tr><td>Nginx welcome page</td><td>DNS and enabled server_name</td><td>Route the hostname to the intended site</td></tr><tr><td>Redirect uses HTTP</td><td>Forwarded scheme and trusted proxy IP</td><td>Keep Nginx headers and Uvicorn trust aligned</td></tr><tr><td>Certificate validation fails</td><td>Public DNS, port 80 and AAAA record</td><td>Correct the challenge path and network reachability</td></tr><tr><td>413 or streaming/WebSocket issues</td><td>Nginx body limits, buffering and upgrade settings</td><td>Configure the application-specific proxy behavior</td></tr></tbody></table></figure>



<h2 id="maintain" class="wp-block-heading">8. Deploy FastAPI updates and plan capacity</h2>



<p class="wp-block-paragraph">For application updates, retain a known working release and dependency set, run your tests, deploy the reviewed code, and restart <code>sudo systemctl restart fastapi</code>. Recheck local and public health endpoints. Run <code>daemon-reload</code> before restarting if the unit file changes. A restart can briefly interrupt requests; this single-server setup does not provide zero-downtime releases.</p>



<p class="wp-block-paragraph">Start with the one worker shown. Increase workers only after measuring CPU, memory and database-connection usage. Each process has its own memory and application state; background tasks or startup jobs may run in each worker. Use shared persistent storage and appropriate job coordination. See <a href="https://fastapi.tiangolo.com/deployment/server-workers/" rel="noopener">FastAPI’s worker guidance</a>.</p>



<p class="wp-block-paragraph">Protect production documentation and administrative endpoints as appropriate, back up persistent data off-server, monitor errors and disk growth, and keep Ubuntu and dependencies maintained. The empty environment-file creation command is a first-install step; do not rerun it over a populated settings file.</p>



<p class="wp-block-paragraph">Our <a href="https://www.aveshost.com/self-managed-vps-hosting" rel="noopener">self-managed VPS hosting</a> suits teams that want control of this stack. Size the server for your actual workload and management needs; <a href="https://www.aveshost.com/support" rel="noopener">contact our support team</a> to discuss the deployment. Our <a href="https://blog.aveshost.com/docker-disk-space-full/">VPS storage troubleshooting guide</a> is useful when logs or deployment artifacts fill a server.</p>



<h2 id="faq" class="wp-block-heading">Frequently asked questions</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="faq-question-60f4db7d85054bdcba3bc74e43dfab88" class="rank-math-list-item">
<h3 class="rank-math-question ">Do I need Gunicorn to deploy FastAPI on a VPS?</h3>
<div class="rank-math-answer ">

<p>No. This setup uses Uvicorn directly under systemd. Uvicorn can run worker processes itself; choose a process model based on measured load and memory rather than adding a second manager automatically.</p>

</div>
</div>
<div id="faq-question-367e44d8e9f34581b2fec6553a27e78c" class="rank-math-list-item">
<h3 class="rank-math-question ">Should I run Uvicorn with &#8211;reload in production?</h3>
<div class="rank-math-answer ">

<p>No. Reload mode is intended for development. Deploy a reviewed release and restart the supervised service deliberately. Keep the application bound to localhost behind Nginx.</p>

</div>
</div>
<div id="faq-question-da375db5144f418ebdc4a51cc8e22f9b" class="rank-math-list-item">
<h3 class="rank-math-question ">Why does FastAPI work on localhost but return 502 through Nginx?</h3>
<div class="rank-math-answer ">

<p>Compare proxy_pass with the actual listening address and port, then inspect Nginx’s error log. Verify the enabled site configuration and whether the app is still running when the proxy request arrives.</p>

</div>
</div>
<div id="faq-question-2611c4d5ca7245adbf70539d9caa94c1" class="rank-math-list-item">
<h3 class="rank-math-question ">Does my API need its own certificate inside Uvicorn?</h3>
<div class="rank-math-answer ">

<p>Not in this same-host design. Nginx handles public HTTPS and forwards HTTP over loopback. If the upstream moves to another server or network, reassess encryption and trust for that connection.</p>

</div>
</div>
<div id="faq-question-afe3015930f04fd191e483a589b6f5b0" class="rank-math-list-item">
<h3 class="rank-math-question ">Can I deploy an existing database-backed FastAPI project this way?</h3>
<div class="rank-math-answer ">

<p>Yes, but add its pinned dependencies, environment settings, database connectivity, migrations, backups and readiness checks. Preserve persistent data outside disposable releases and plan rollback around schema compatibility.</p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/deploy-fastapi-ubuntu-vps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Deploy Node.js, Python and Laravel Apps on a Linux VPS</title>
		<link>https://blog.aveshost.com/deploy-web-apps-linux-vps/</link>
					<comments>https://blog.aveshost.com/deploy-web-apps-linux-vps/#respond</comments>
		
		<dc:creator><![CDATA[James Wilson]]></dc:creator>
		<pubDate>Mon, 12 Oct 2026 18:43:10 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[vps hosting]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=4995</guid>

					<description><![CDATA[To deploy a web app on a Linux VPS, install the right runtime, run the application as a supervised service, place Nginx in front of it and enable HTTPS. Node.js, Python and Laravel share this foundation, but each needs a different application server and launch command. A VPS gives you the freedom to choose framework [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><strong>To deploy a web app on a Linux VPS, install the right runtime, run the application as a supervised service, place Nginx in front of it and enable HTTPS.</strong> Node.js, Python and Laravel share this foundation, but each needs a different application server and launch command.</p>



<p class="wp-block-paragraph">A VPS gives you the freedom to choose framework versions, connect databases, run background workers and host several projects under your own domains. Our <a href="https://www.aveshost.com/self-managed-vps-hosting" rel="noopener">self-managed cloud VPS plans</a> give you full root access to build that environment your way.</p>



<p class="wp-block-paragraph">This guide walks through an Ubuntu 24.04 LTS server with Nginx, systemd and SSL. Complete the shared preparation, choose the section for your framework, then finish with the domain, HTTPS and maintenance steps. You do not need to install all three stacks to deploy one app.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#choose">Choose the right Linux VPS for your web app</a></div><div><a href="#prepare">1. Prepare Ubuntu, SSH and your firewall</a></div><div><a href="#code">2. Upload your code and protect configuration</a></div><div><a href="#node">3. Deploy a Node.js app on your VPS</a></div><div><a href="#python">4. Deploy a Python app with Gunicorn</a></div><div><a href="#laravel">5. Deploy Laravel with PHP-FPM</a></div><div><a href="#nginx">6. Configure Nginx and your domain</a></div><div><a href="#ssl">7. Enable HTTPS with SSL certificates</a></div><div><a href="#operate">8. Add backups, monitoring and safe updates</a></div><div><a href="#troubleshoot">Troubleshoot common VPS deployment errors</a></div><div><a href="#faq">Frequently asked questions</a></div></div></nav></div>



<h2 id="choose" class="wp-block-heading">Choose the right Linux VPS for your web app</h2>



<p class="wp-block-paragraph">Choose resources around your workload rather than the programming language alone. A small API needs less memory than a dashboard with database queries, queues and a frontend build. Build tools can briefly consume more RAM than the running app, so leave room for deployment tasks as well as everyday traffic.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Our plan</th><th>Monthly USD price</th><th>CPU / RAM / storage</th><th>Suggested starting use</th></tr></thead><tbody><tr><td>Cloud VPS 1</td><td>$9.13</td><td>1 vCore / 2 GB / 20 GB SSD</td><td>Small app, prototype or lightweight API</td></tr><tr><td>Cloud VPS 2</td><td>$15.51</td><td>4 vCores / 8 GB / 100 GB SSD</td><td>App plus database, builds and background jobs</td></tr><tr><td>Cloud VPS 3</td><td>$27.38</td><td>6 vCores / 12 GB / 200 GB SSD</td><td>Several apps or a busier production workload</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Prices above are the USD display on our plan page at the time of writing. Select your currency and billing options to see your checkout total. For a first production deployment with a local database, Cloud VPS 2 provides useful headroom; measure memory use, CPU and response times as traffic grows.</p>



<p class="wp-block-paragraph">Our self-managed VPS gives you control over the Linux environment without a bundled cPanel or DirectAdmin licence. This tutorial uses SSH and command-line tools. If you want a control panel, explore our <a href="https://www.aveshost.com/fully-managed-vps-hosting" rel="noopener">fully managed VPS options</a>. For an interface that handles Git deployments and containers, follow our <a href="https://blog.aveshost.com/coolify-on-a-vps/">Coolify deployment guide</a>.</p>



<ul class="wp-block-list">
<li>A fresh Ubuntu 24.04 LTS VPS with its public IP and administrative access.</li>



<li>A domain or subdomain whose DNS records you can edit.</li>



<li>A tested application, dependency lockfile and known production start command.</li>



<li>An SSH client, a Git repository or secure file transfer access.</li>



<li>Database credentials and a recovery plan before importing existing data.</li>
</ul>



<figure class="wp-block-image size-full"><img decoding="async" width="1942" height="809" src="https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture.webp" alt="Linux VPS app architecture with Nginx, private runtimes and a database" class="wp-image-4998" srcset="https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture.webp 1942w, https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture-300x125.webp 300w, https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture-1024x427.webp 1024w, https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture-768x320.webp 768w, https://blog.aveshost.com/wp-content/uploads/2026/10/vps-app-architecture-1536x640.webp 1536w" sizes="(max-width: 1942px) 100vw, 1942px" /><figcaption class="wp-element-caption">Nginx handles public traffic while your application runtime and database remain private.</figcaption></figure>



<h2 id="prepare" class="wp-block-heading">1. Prepare Ubuntu, SSH and your firewall</h2>



<p class="wp-block-paragraph">Start with a fresh server. These commands use the default SSH port, 22. If your server uses another port, allow that actual port before enabling the firewall. Keep the current SSH session open until a second connection works.</p>



<pre class="wp-block-code"><code>ssh root@YOUR_SERVER_IP
apt update
apt upgrade
apt install nginx git curl ca-certificates ufw
adduser deploy
usermod -aG sudo deploy</code></pre>



<p class="wp-block-paragraph">Replace YOUR_SERVER_IP with your server address. On your own computer, create an SSH key if you do not already have one, then add its public key to the deploy account. Never upload or share the private key.</p>



<pre class="wp-block-code"><code>ssh-keygen -t ed25519
ssh-copy-id deploy@YOUR_SERVER_IP
ssh deploy@YOUR_SERVER_IP</code></pre>



<p class="wp-block-paragraph">Run the remaining commands as deploy with sudo where shown. On Windows, use OpenSSH or your SSH client to place the public key in /home/deploy/.ssh/authorized_keys if ssh-copy-id is unavailable. Set the .ssh directory to mode 700 and authorized_keys to 600, owned by deploy.</p>



<pre class="wp-block-code"><code>sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status
sudo systemctl enable --now nginx</code></pre>



<p class="wp-block-paragraph">Only SSH and the public web ports should be reachable for this setup. Node.js and Python will listen on loopback, while PHP-FPM uses a local socket. Do not open database, cache or application ports to the whole internet. Read the <a href="https://ubuntu.com/server/docs/how-to/security/firewalls/" rel="noopener">Ubuntu firewall documentation</a> when adapting rules to your network.</p>



<p class="wp-block-paragraph">After key-based access works in a second session, harden SSH with your chosen access policy. Make configuration changes carefully, check them with sudo sshd -t and keep a recovery route through the server console. Apply security updates regularly and plan reboots when the operating system requires them.</p>



<h2 id="code" class="wp-block-heading">2. Upload your code and protect configuration</h2>



<p class="wp-block-paragraph">Each example uses a separate project directory: /srv/nodeapp, /srv/pythonapp or /srv/laravelapp. Choose your app directory and replace YOUR_REPOSITORY_URL with your repository address. Use a read-only deployment key or repository access token with minimal permissions for a private repository; do not put credentials into the URL or shell history.</p>



<pre class="wp-block-code"><code>sudo install -d -o deploy -g deploy /srv/nodeapp
git clone YOUR_REPOSITORY_URL /srv/nodeapp
cd /srv/nodeapp</code></pre>



<p class="wp-block-paragraph">For Python or Laravel, substitute the relevant directory in all three commands. Deploy a tested release or commit instead of blindly pulling whatever happens to be on the default branch. Keep package-lock.json, your Python dependency lock or composer.lock in version control for reproducible installs.</p>



<p class="wp-block-paragraph">Keep database passwords, API keys and signing secrets out of Git. For the Node.js and Python service examples, store runtime variables in a root-owned file under /etc, readable by systemd. The application must actually read those variables; an environment file does not configure your code by itself.</p>



<pre class="wp-block-code"><code>sudo install -d -m 700 /etc/webapps
sudo install -m 600 /dev/null /etc/webapps/nodeapp.env
sudoedit /etc/webapps/nodeapp.env</code></pre>



<p class="wp-block-paragraph">Use ordinary KEY=value entries compatible with systemd EnvironmentFile syntax. The Node example needs NODE_ENV=production and PORT=3000; add your application-specific variables separately. Create pythonapp.env the same way for the Python branch. Laravel uses its project .env file, configured in its own section. Never paste real secrets into a public support ticket.</p>



<h2 id="node" class="wp-block-heading">3. Deploy a Node.js app on your VPS</h2>



<h3 id="node-runtime" class="wp-block-heading">Install a supported Node.js LTS runtime</h3>



<p class="wp-block-paragraph">Use a Node.js LTS release supported by your app and dependencies. Do not rely on an old distribution package simply because its installation is convenient. Visit the <a href="https://nodejs.org/en/download" rel="noopener">official Node.js download page</a>, select the Linux binary matching your server architecture and verify its checksum against the published release files before installing it.</p>



<p class="wp-block-paragraph">The service below expects a system-wide installation at /opt/node/bin/node and npm at /opt/node/bin/npm. Extract your verified binary archive into /opt/node with its top-level directory removed, or adapt the absolute paths to your trusted installation. Do not hard-code a path inside another user’s home directory. Confirm the installed version and permissions before continuing.</p>



<p class="wp-block-paragraph">After downloading and verifying the official archive, transfer it securely to the VPS. Replace NODE_ARCHIVE with its exact filename in the command below. This installs the runtime at the path used by the example service; use it on a fresh setup, and preserve the previous runtime when planning future upgrades.</p>



<pre class="wp-block-code"><code>sudo install -d -m 755 /opt/node
sudo tar -xJf NODE_ARCHIVE --strip-components=1 -C /opt/node
sudo chown -R root:root /opt/node</code></pre>



<pre class="wp-block-code"><code>/opt/node/bin/node --version
/opt/node/bin/npm --version
cd /srv/nodeapp
PATH=/opt/node/bin:$PATH /opt/node/bin/npm ci
PATH=/opt/node/bin:$PATH /opt/node/bin/npm run build --if-present</code></pre>



<p class="wp-block-paragraph">Install build dependencies first, produce the build, then decide whether development packages can be pruned. Some apps need packages at runtime that are incorrectly listed as development dependencies; test before removing them. The production entry point in this example is server.js. For a compiled app, replace it with the actual output file, such as dist/server.js.</p>



<h3 id="node-service" class="wp-block-heading">Keep Node.js running with systemd</h3>



<p class="wp-block-paragraph">Configure the application to bind to 127.0.0.1:3000. For an Express app, the listening call could be app.listen(process.env.PORT || 3000, &#8220;127.0.0.1&#8221;). Create /etc/systemd/system/nodeapp.service with:</p>



<pre class="wp-block-code"><code>&#91;Unit]
Description=Node.js web application
After=network.target

&#91;Service]
Type=simple
User=deploy
Group=deploy
WorkingDirectory=/srv/nodeapp
EnvironmentFile=/etc/webapps/nodeapp.env
ExecStart=/opt/node/bin/node /srv/nodeapp/server.js
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true

&#91;Install]
WantedBy=multi-user.target</code></pre>



<pre class="wp-block-code"><code>sudo systemctl daemon-reload
sudo systemctl enable --now nodeapp
sudo systemctl status nodeapp
curl -I http://127.0.0.1:3000
sudo journalctl -u nodeapp -n 50 --no-pager</code></pre>



<p class="wp-block-paragraph">A successful HTTP response proves the app is reachable locally; use a known route if your app does not answer HEAD requests at /. systemd starts the service after a reboot and restarts it after a process failure. You do not need to add a second process manager for this setup. If your framework requires npm start, configure a service command and PATH that match that production script.</p>



<h2 id="python" class="wp-block-heading">4. Deploy a Python app with Gunicorn</h2>



<p class="wp-block-paragraph">For a WSGI application such as Flask or conventional Django, use Gunicorn rather than the framework development server. The example below is Flask with app.py exporting an application object called app. A Django deployment usually changes the target to projectname.wsgi:application.</p>



<pre class="wp-block-code"><code>sudo apt install python3-venv python3-pip
cd /srv/pythonapp
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python -m pip install gunicorn</code></pre>



<p class="wp-block-paragraph">For repeatable releases, record Gunicorn and other production packages in your tested requirements or lockfile. Avoid sudo pip install into the system Python. Virtual environments keep each app’s dependencies separate.</p>



<p class="wp-block-paragraph">Create /etc/webapps/pythonapp.env using the protected-file procedure above, with the variables your application expects. Then save /etc/systemd/system/pythonapp.service:</p>



<pre class="wp-block-code"><code>&#91;Unit]
Description=Python web application
After=network.target

&#91;Service]
Type=simple
User=deploy
Group=deploy
WorkingDirectory=/srv/pythonapp
EnvironmentFile=/etc/webapps/pythonapp.env
ExecStart=/srv/pythonapp/.venv/bin/gunicorn --workers 2 --bind 127.0.0.1:8000 --access-logfile - --error-logfile - app:app
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true

&#91;Install]
WantedBy=multi-user.target</code></pre>



<pre class="wp-block-code"><code>sudo systemctl daemon-reload
sudo systemctl enable --now pythonapp
sudo systemctl status pythonapp
curl -I http://127.0.0.1:8000
sudo journalctl -u pythonapp -n 50 --no-pager</code></pre>



<p class="wp-block-paragraph">Two workers are a starting configuration, not a universal sizing rule. Tune workers against memory, CPU and request latency. If your app uses an application factory, use the appropriate factory import. See the <a href="https://flask.palletsprojects.com/en/stable/deploying/gunicorn/" rel="noopener">Flask Gunicorn guide</a> for supported loading patterns.</p>



<p class="wp-block-paragraph">For Django, set DEBUG=False, configure ALLOWED_HOSTS, run migrations, collect static files and arrange persistent media storage before launch. Configure proxy-related HTTPS settings only when you trust the forwarding proxy. FastAPI and other ASGI apps need an ASGI server such as Uvicorn; do not copy the WSGI app:app command into an ASGI deployment.</p>



<h2 id="laravel" class="wp-block-heading">5. Deploy Laravel with PHP-FPM</h2>



<p class="wp-block-paragraph">Laravel runs through PHP-FPM in this guide. Ubuntu 24.04 supplies PHP 8.3 packages, suitable for Laravel versions whose PHP requirements allow 8.3. Check your project’s composer.json and installed extensions before deployment, especially for applications with newer or specialised dependencies.</p>



<pre class="wp-block-code"><code>sudo apt install php8.3-fpm php8.3-cli php8.3-mbstring php8.3-xml php8.3-curl php8.3-zip php8.3-mysql php8.3-bcmath unzip composer
cd /srv/laravelapp
composer install --no-dev --prefer-dist --optimize-autoloader
composer check-platform-reqs
cp .env.example .env
chmod 640 .env</code></pre>



<p class="wp-block-paragraph">For PostgreSQL, install the matching PHP PostgreSQL extension instead of using the MySQL driver alone. Run Composer as deploy rather than root. Check whether your project requires a newer Composer release; use the official Composer installation instructions when the Ubuntu package does not meet its requirements.</p>



<p class="wp-block-paragraph">Edit .env with APP_ENV=production, APP_DEBUG=false, APP_URL=https://app.example.com and the database, mail, queue and session settings your app uses. For a new application, generate APP_KEY once. For an existing application, preserve its original key: changing it can invalidate encrypted data.</p>



<pre class="wp-block-code"><code>php artisan key:generate
# Run the command above only for a new app without an existing key.
# Back up an existing database before applying migrations.
php artisan migrate --force
php artisan optimize</code></pre>



<p class="wp-block-paragraph">Provision the database and a dedicated application user before migrating; give that user only the privileges required for the project. Keep the database on loopback or a private network. Never use the database root account as the application login. If the project builds frontend assets, install its supported Node.js runtime, run npm ci and npm run build, then verify the asset manifest is present.</p>



<h3 id="laravel-permissions" class="wp-block-heading">Set writable directories without opening the whole project</h3>



<pre class="wp-block-code"><code>sudo chgrp -R www-data /srv/laravelapp
sudo chmod -R g+rX /srv/laravelapp
sudo chmod 640 /srv/laravelapp/.env
sudo find /srv/laravelapp/storage /srv/laravelapp/bootstrap/cache -type d -exec chmod 2770 {} \;
sudo find /srv/laravelapp/storage /srv/laravelapp/bootstrap/cache -type f -exec chmod 660 {} \;
sudo systemctl enable --now php8.3-fpm</code></pre>



<p class="wp-block-paragraph">These permissions let the PHP-FPM group write to storage and bootstrap/cache while keeping the source owned by deploy. Avoid chmod 777. Ensure newly deployed files retain the required group permissions. If your app uses public uploads, run php artisan storage:link and back up the underlying storage directory.</p>



<p class="wp-block-paragraph">Set Nginx’s document root to /srv/laravelapp/public, never the project root. See the <a href="https://laravel.com/framework/docs/deployment" rel="noopener">Laravel deployment documentation</a> for framework requirements and production configuration.</p>



<h3 id="laravel-jobs" class="wp-block-heading">Supervise queues and schedule recurring tasks</h3>



<p class="wp-block-paragraph">If you use an asynchronous queue, create a separate systemd worker with User=deploy, WorkingDirectory=/srv/laravelapp and ExecStart=/usr/bin/php /srv/laravelapp/artisan queue:work &#8211;sleep=3 &#8211;tries=3 &#8211;timeout=90. Use Restart=always and a generous TimeoutStopSec for your longest job. Set the queue connection’s retry_after higher than the worker timeout, and make jobs safe to retry. Reload workers after deploying new code.</p>



<p class="wp-block-paragraph">For scheduled tasks, add this entry to the deploy user’s crontab using crontab -e. Choose a log path and monitoring strategy if you need visibility into scheduler output:</p>



<pre class="wp-block-code"><code>* * * * * cd /srv/laravelapp &amp;&amp; /usr/bin/php artisan schedule:run &gt;&gt; /dev/null 2&gt;&amp;1</code></pre>



<h2 id="nginx" class="wp-block-heading">6. Configure Nginx and your domain</h2>



<p class="wp-block-paragraph">Create an A record for app.example.com pointing to your VPS IPv4 address. Add an AAAA record only if IPv6 is configured and reachable on this server. Replace app.example.com throughout with your real hostname. If you still need a domain, use our <a href="https://www.aveshost.com/domains" rel="noopener">domain search</a>.</p>



<h3 id="proxy" class="wp-block-heading">Nginx for Node.js or Python</h3>



<p class="wp-block-paragraph">Create /etc/nginx/sites-available/app with the following HTTP configuration. Node.js uses port 3000; for the Python branch, change proxy_pass to http://127.0.0.1:8000. Use a separate file and hostname for each application when hosting several apps.</p>



<pre class="wp-block-code"><code>server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}</code></pre>



<p class="wp-block-paragraph">If your app needs WebSockets, add the appropriate Upgrade and Connection handling for its endpoint. Configure upload limits and timeouts around genuine requirements. Do not increase limits indiscriminately to hide slow database queries or blocked workers. Apps that generate absolute URLs or secure cookies need correctly scoped proxy trust settings.</p>



<h3 id="php-nginx" class="wp-block-heading">Nginx for Laravel</h3>



<p class="wp-block-paragraph">Use this configuration instead of the Node.js/Python proxy block for the Laravel branch. Check the installed PHP-FPM socket if you use a different PHP version.</p>



<pre class="wp-block-code"><code>server {
    listen 80;
    server_name app.example.com;
    root /srv/laravelapp/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^/index\.php(/|$) {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    location ~ \.php$ {
        return 404;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}</code></pre>



<p class="wp-block-paragraph">Enable your chosen configuration, test syntax and reload Nginx. The symbolic link command below is for a new site; skip it if the same link already exists.</p>



<pre class="wp-block-code"><code>sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/app
sudo nginx -t
sudo systemctl reload nginx
curl -I -H "Host: app.example.com" http://127.0.0.1</code></pre>



<p class="wp-block-paragraph">If the default welcome page appears when using your domain, check server_name, DNS and enabled sites before removing any configuration. On a server with existing websites, do not delete their site files. Test public reachability with a harmless health route; keep real sign-ins and sensitive data off HTTP until HTTPS is ready.</p>



<h2 id="ssl" class="wp-block-heading">7. Enable HTTPS with SSL certificates</h2>



<p class="wp-block-paragraph">Once your hostname reaches the correct Nginx site, issue a certificate and redirect HTTP to HTTPS. The following uses Certbot’s snap installation for a fresh server, following the <a href="https://certbot.eff.org/instructions?ws=nginx&amp;os=snap" rel="noopener">official Nginx instructions</a>. Do not mix competing Certbot installations on an existing server.</p>



<pre class="wp-block-code"><code>sudo apt install snapd
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot
sudo certbot --nginx -d app.example.com
sudo certbot renew --dry-run</code></pre>



<p class="wp-block-paragraph">Skip the symlink step if /usr/local/bin/certbot already points to the intended snap binary. Follow the prompts with your contact email and choose HTTPS redirection if offered. Certbot’s renewal validation must remain reachable: keep DNS correct and ensure the challenge route is not blocked by authentication or firewall rules.</p>



<p class="wp-block-paragraph">Visit https://app.example.com, verify the certificate and test sign-in, forms, uploads and callback URLs. If a CDN or proxy is in front, maintain encryption between it and the VPS as well. Use our <a href="https://blog.aveshost.com/protect-your-website-with-cloudflare/">step-by-step Cloudflare protection guide</a> for that additional layer. Delay strict long-lived HSTS settings until HTTPS works across the hostnames you intend to cover.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1672" height="941" src="https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist.webp" alt="Production web app checklist covering SSH, private ports, HTTPS, restarts, backups and health checks" class="wp-image-4999" srcset="https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist.webp 1672w, https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist-300x169.webp 300w, https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist-1024x576.webp 1024w, https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist-768x432.webp 768w, https://blog.aveshost.com/wp-content/uploads/2026/10/app-deployment-checklist-1536x864.webp 1536w" sizes="(max-width: 1672px) 100vw, 1672px" /><figcaption class="wp-element-caption">Check security, recovery and service health before opening your app to users.</figcaption></figure>



<h2 id="operate" class="wp-block-heading">8. Add backups, monitoring and safe updates</h2>



<p class="wp-block-paragraph">Deployment is complete when the application survives a restart, handles its expected requests and can be recovered from a failure. Build a simple maintenance routine before your first customer depends on it.</p>



<ul class="wp-block-list">
<li>Back up the database with its native backup tool, plus uploads, configuration and required secrets. Protect backup access and encryption keys.</li>



<li>Keep a separate recovery copy and test restoring it to a clean environment. A copy of a live database directory is not automatically a consistent backup.</li>



<li>Monitor uptime, response times, memory, disk usage and certificate renewal. Configure actionable alerts rather than relying on users to report outages.</li>



<li>Keep logs useful without recording passwords, session tokens or full sensitive request bodies. Rotate logs and watch disk capacity.</li>



<li>Apply operating-system and dependency security updates through tested releases. Schedule disruptive changes and verify the app afterwards.</li>
</ul>



<h3 id="release" class="wp-block-heading">Deploy updates with a rollback plan</h3>



<p class="wp-block-paragraph">Tag or record the current release, create a database backup before schema changes and deploy the next tested version. Build before switching traffic where practical. For Node.js or Python, restart the relevant service and inspect its journal. For Laravel, rebuild caches, migrate deliberately and restart queue workers so they load new code.</p>



<pre class="wp-block-code"><code>sudo systemctl restart nodeapp
sudo journalctl -u nodeapp -n 50 --no-pager
# For Python, replace nodeapp with pythonapp.
# For Laravel queue workers, run from the project directory:
php artisan queue:restart</code></pre>



<p class="wp-block-paragraph">Run only the commands for your branch. For a rollback, restore the previous release and its compatible configuration. A database migration can make older code incompatible, so plan backward-compatible schema changes or a controlled database restore. For more advanced releases, use separate release directories and a current symlink, keeping uploads and secrets outside disposable release folders.</p>



<p class="wp-block-paragraph">Reboot during a planned window and confirm Nginx, the app service, PHP-FPM where applicable and any database or queue services return correctly. A service showing active is only one check; make a real request to the application’s health endpoint and a representative user flow.</p>



<h2 id="troubleshoot" class="wp-block-heading">Troubleshoot common VPS deployment errors</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Symptom</th><th>Likely area</th><th>First checks</th></tr></thead><tbody><tr><td>502 Bad Gateway</td><td>Application process, port or FPM socket</td><td>Check systemctl status, journalctl and the Nginx error log; compare upstream addresses.</td></tr><tr><td>403 Forbidden</td><td>Document root or permissions</td><td>Check parent-directory traversal permissions and Laravel public root; avoid 777.</td></tr><tr><td>Laravel 500 error</td><td>Environment, database or writable storage</td><td>Inspect storage/logs, APP_KEY, database access and storage permissions; keep debug off publicly.</td></tr><tr><td>Wrong site appears</td><td>DNS or Nginx server_name</td><td>Check A/AAAA records and enabled site names.</td></tr><tr><td>SSL issuance fails</td><td>DNS, HTTP challenge or firewall</td><td>Verify the domain reaches this server on port 80; inspect IPv6 and proxy rules.</td></tr><tr><td>App stops after SSH logout</td><td>Process was started interactively</td><td>Install and enable the appropriate systemd service.</td></tr><tr><td>Server slows during builds</td><td>Memory, CPU or disk pressure</td><td>Check free -h, df -h and process load; build in CI or choose more headroom.</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Useful diagnostic commands include sudo nginx -t, sudo tail -n 50 /var/log/nginx/error.log, sudo systemctl status nodeapp and sudo journalctl -u pythonapp -n 50 &#8211;no-pager. Adapt the service name to your app. Fix the underlying error rather than repeatedly restarting services or exposing private ports.</p>



<p class="wp-block-paragraph">Ready to put your app online? <a href="https://www.aveshost.com/self-managed-vps-hosting" rel="noopener">Choose your self-managed cloud VPS</a>, select a location close to your audience and follow the branch for your framework. If you need help choosing resources or a control-panel option, <a href="https://www.aveshost.com/support" rel="noopener">contact our team</a> with your stack, expected traffic and storage needs.</p>



<h2 id="faq" class="wp-block-heading">Frequently asked questions</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="deploy-faq-0" class="rank-math-list-item">
<h3 class="rank-math-question ">Can I deploy Node.js, Python and Laravel on the same VPS?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Yes. Give each app its own directory, service and hostname. Use different local ports for Node.js and Python, and a PHP-FPM configuration for Laravel. Size the VPS for the combined workloads and use separate database credentials and configuration files.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-1" class="rank-math-list-item">
<h3 class="rank-math-question ">Which VPS plan should I start with?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>A lightweight app can start with a small plan, while an app with a database, builds and background jobs benefits from more headroom. Our Cloud VPS 2 includes 4 vCores, 8 GB RAM and 100 GB SSD storage. Monitor usage and choose resources around your workload.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-2" class="rank-math-list-item">
<h3 class="rank-math-question ">Do I need cPanel to deploy a web app?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>No. This guide uses SSH, Nginx and systemd on our self-managed VPS. A control panel is optional. Our fully managed VPS options include control-panel choices such as cPanel or DirectAdmin.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-3" class="rank-math-list-item">
<h3 class="rank-math-question ">What keeps my Node.js or Python app running after logout?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>A systemd service runs independently of your SSH session, starts on boot when enabled and can restart a failed process. Use the production launch command and check both service status and real HTTP responses.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-4" class="rank-math-list-item">
<h3 class="rank-math-question ">Should I use Flask run or php artisan serve in production?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Use a production application server. This guide uses Gunicorn for WSGI Python apps and PHP-FPM behind Nginx for Laravel. Development servers are intended for development and testing.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-5" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I deploy FastAPI on a VPS?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Use an ASGI server such as Uvicorn with a supervised service, bind it to a private local port and put Nginx in front. The Gunicorn WSGI command in the Python example is for a WSGI application and must be adapted for ASGI.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-6" class="rank-math-list-item">
<h3 class="rank-math-question ">Can I get a free SSL certificate for my VPS app?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Yes. Certbot can obtain a Let’s Encrypt certificate for a domain that correctly reaches your server. Configure Nginx, allow the required validation traffic and test automated renewal.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-7" class="rank-math-list-item">
<h3 class="rank-math-question ">Why does Nginx show 502 Bad Gateway?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Nginx cannot get a valid response from its upstream. Check whether the app or PHP-FPM is running, whether its port or socket matches the site configuration, and what the service and Nginx logs report.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-8" class="rank-math-list-item">
<h3 class="rank-math-question ">Where should I store application secrets?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Keep secrets out of Git and public web directories. The Node.js and Python examples use protected environment files under /etc. Laravel uses a restricted .env file outside its public document root. Preserve existing signing and encryption keys during migration.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
<div id="deploy-faq-9" class="rank-math-list-item">
<h3 class="rank-math-question ">What should I back up before updating my app?</h3>
<div class="rank-math-answer ">

<p><!-- wp:paragraph --></p>
<p>Back up the database with a consistent native backup, uploaded files, required configuration and secrets. Record the current release and test restoration. Plan database compatibility before rolling code back.</p>
<p><!-- /wp:paragraph --></p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/deploy-web-apps-linux-vps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
