<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aman Kumar</title>
    <description>The latest articles on DEV Community by Aman Kumar (@aman1432).</description>
    <link>https://dev.to/aman1432</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3980744%2F02a4192a-a4cd-40b7-bf8c-e76355431b52.png</url>
      <title>DEV Community: Aman Kumar</title>
      <link>https://dev.to/aman1432</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aman1432"/>
    <language>en</language>
    <item>
      <title>How to Host a Full PHP Web Server for FREE in 2026 (LAMP Stack on Hugging Face)</title>
      <dc:creator>Aman Kumar</dc:creator>
      <pubDate>Fri, 12 Jun 2026 07:34:09 +0000</pubDate>
      <link>https://dev.to/aman1432/how-to-host-a-full-php-web-server-for-free-in-2026-lamp-stack-on-hugging-face-1eng</link>
      <guid>https://dev.to/aman1432/how-to-host-a-full-php-web-server-for-free-in-2026-lamp-stack-on-hugging-face-1eng</guid>
      <description>&lt;p&gt;Let’s be real—setting up a traditional VPS or paying monthly for shared hosting just to run some personal PHP projects, APIs, or lightweight apps can be a hassle. As developers, we want to focus on hands-on implementation and real-world logic, not server administration bills. &lt;/p&gt;

&lt;p&gt;I wanted a complete, production-like PHP environment that I could deploy anywhere for &lt;strong&gt;free&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Since platforms like Hugging Face Spaces offer free Docker hosting (primarily meant for AI Python apps), I decided to push the limits. I built a &lt;strong&gt;single-container Alpine LAMP stack&lt;/strong&gt; that runs perfectly on Hugging Face, complete with MariaDB, PHP 8.x (FPM), Apache (MPM Event), and even an integrated Web Terminal.&lt;/p&gt;

&lt;p&gt;Here is how you can set it up for yourself. 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  📦 What's Inside the Box?
&lt;/h2&gt;

&lt;p&gt;Instead of the standard "one process per container" Docker rule, I engineered a lightweight Alpine image that handles everything gracefully using &lt;code&gt;tini&lt;/code&gt; and a custom supervisor script. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;🐘 PHP 8.x (FPM):&lt;/strong&gt; High-performance runtime with OPcache.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🌐 Apache (MPM Event):&lt;/strong&gt; High-concurrency setup with &lt;code&gt;mod_rewrite&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🗄️ MariaDB:&lt;/strong&gt; Database engine + phpMyAdmin pre-configured.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📁 Custom File Manager &amp;amp; Web Terminal:&lt;/strong&gt; Direct browser-based control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎬 Media Ready:&lt;/strong&gt; FFmpeg and ImageMagick pre-installed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check out the full source code and Dockerfile here:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://github.com/shkumaraman/free-web-hosting" rel="noopener noreferrer"&gt;GitHub Repo: free-web-hosting&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;(Drop a ⭐ if you find it useful!)&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  ☁️ How to Deploy on Hugging Face Spaces (For Free)
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Create the Space
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://huggingface.co/spaces" rel="noopener noreferrer"&gt;Hugging Face Spaces&lt;/a&gt; and click &lt;strong&gt;Create new Space&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Give it a name (e.g., &lt;code&gt;my-php-server&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Docker&lt;/strong&gt; as the SDK and choose &lt;strong&gt;Public&lt;/strong&gt; visibility.&lt;/li&gt;
&lt;li&gt;Click Create.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Step 2: Upload the Dockerfile
&lt;/h3&gt;

&lt;p&gt;You don't need to upload your entire website code yet. Just grab the &lt;code&gt;Dockerfile&lt;/code&gt; from my GitHub repository and upload it directly into your Space's &lt;strong&gt;Files&lt;/strong&gt; tab. &lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Set Your Environment Variables
&lt;/h3&gt;

&lt;p&gt;Go to &lt;strong&gt;Settings → Variables and Secrets&lt;/strong&gt; and configure your database and paths. This keeps your server secure from the public:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;MYSQL_USER&lt;/code&gt; = &lt;code&gt;admin&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MYSQL_PASSWORD&lt;/code&gt; = &lt;code&gt;super-secret-password&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MYSQL_DATABASE&lt;/code&gt; = &lt;code&gt;myapp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SQL_PATH&lt;/code&gt; = &lt;code&gt;hidden-db-panel&lt;/code&gt; (Changes phpMyAdmin URL)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FILES_PATH&lt;/code&gt; = &lt;code&gt;hidden-file-panel&lt;/code&gt; (Changes File Manager URL)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Step 4: Add Persistent Storage (Crucial!)
&lt;/h3&gt;

&lt;p&gt;Hugging Face containers are ephemeral—they reset on rebuilds. To save your databases and website files:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings → Persistent Storage&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Add a mount path at &lt;code&gt;/data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set Visibility to &lt;strong&gt;Private&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Boom! Your space will build, and you now have a live PHP server. &lt;/p&gt;


&lt;h2&gt;
  
  
  🔀 The Magic Trick: Custom Domains via Cloudflare
&lt;/h2&gt;

&lt;p&gt;Hugging Face Spaces use &lt;code&gt;iframe&lt;/code&gt; embedding on their main site, which causes terrible "login loops" with phpMyAdmin and blocks cookies if you try to CNAME it directly. &lt;/p&gt;

&lt;p&gt;To fix this, we can use a &lt;strong&gt;Cloudflare Worker&lt;/strong&gt; to proxy the domain, rewrite the headers, and fix the &lt;code&gt;SameSite&lt;/code&gt; cookie issues.&lt;/p&gt;

&lt;p&gt;Just create a free Cloudflare Worker, attach your custom domain, and paste this routing logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Replace with your HF Space hostname&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;backendHost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your-space.hf.space&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;backendUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="nx"&gt;backendUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;backendHost&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;backendUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newHeaders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;newHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;X-Forwarded-Host&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;newHeaders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;X-Forwarded-Proto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="c1"&gt;// ... [Full Worker Script available in the GitHub Repo README] ...&lt;/span&gt;

      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;statusText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statusText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Worker Error: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(You can find the complete, copy-pasteable Cloudflare Worker code in the &lt;a href="https://github.com/shkumaraman/free-web-hosting" rel="noopener noreferrer"&gt;repository's README&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ Uploading Your Code
&lt;/h2&gt;

&lt;p&gt;Once your server is up, just navigate to &lt;code&gt;https://your-domain.com/hidden-file-panel&lt;/code&gt; (or whatever you set &lt;code&gt;FILES_PATH&lt;/code&gt; to). &lt;br&gt;
Use the built-in File Manager to upload your &lt;code&gt;.zip&lt;/code&gt; project directly to &lt;code&gt;/var/www/localhost/htdocs&lt;/code&gt;, extract it using the Web Terminal, and you are live!&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Owning your infrastructure shouldn't require an expensive monthly subscription. With a bit of Docker magic and Cloudflare routing, you can host robust, real-world applications entirely for free. &lt;/p&gt;

&lt;p&gt;If this guide helped you out, I’d love it if you could star the &lt;a href="https://github.com/shkumaraman/free-web-hosting" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;. Feel free to fork it, modify it, and build something awesome.&lt;/p&gt;

&lt;p&gt;Happy coding! &lt;/p&gt;




&lt;p&gt;&lt;em&gt;P.S. Looking for a modern, real-time messaging experience? Also visit &lt;a href="https://shkumaraman.github.io" rel="noopener noreferrer"&gt;Talkrush&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>docker</category>
      <category>hosting</category>
    </item>
  </channel>
</rss>
