<?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: Artisan</title>
    <description>The latest articles on DEV Community by Artisan (@artisansg).</description>
    <link>https://dev.to/artisansg</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4220122%2F376abb50-b124-4f4d-a53d-0b5e575ef2a3.jpg</url>
      <title>DEV Community: Artisan</title>
      <link>https://dev.to/artisansg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/artisansg"/>
    <language>en</language>
    <item>
      <title>Fixing “No such file or directory” when installing LAMP on Ubuntu</title>
      <dc:creator>Artisan</dc:creator>
      <pubDate>Sun, 01 Nov 2026 07:12:48 +0000</pubDate>
      <link>https://dev.to/artisansg/fixing-no-such-file-or-directory-when-installing-lamp-on-ubuntu-5bpm</link>
      <guid>https://dev.to/artisansg/fixing-no-such-file-or-directory-when-installing-lamp-on-ubuntu-5bpm</guid>
      <description>&lt;p&gt;Installing a LAMP stack on Ubuntu &lt;em&gt;should&lt;/em&gt; be boring: &lt;code&gt;apt install&lt;/code&gt;, start services, load a test page, done.&lt;/p&gt;

&lt;p&gt;In reality, it’s common to get hit with errors like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;No such file or directory&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;command not found&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;permission denied&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bad file descriptor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Apache/MySQL won’t start after install&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post is a practical, copy/paste-friendly checklist to get you unstuck, based on SudoGuide’s troubleshooting flow and the typical root causes behind these failures. &lt;/p&gt;

&lt;h2&gt;
  
  
  What “No such file or directory” usually &lt;em&gt;really&lt;/em&gt; means
&lt;/h2&gt;

&lt;p&gt;When you see “No such file or directory” during a LAMP install, it rarely means “your server randomly lost a file.”&lt;/p&gt;

&lt;p&gt;It usually means one of these is true:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Your package lists are stale&lt;/strong&gt; (you didn’t run &lt;code&gt;apt update&lt;/code&gt;, or a repo is failing).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies are broken&lt;/strong&gt; (a previous install was interrupted and dpkg is half-configured).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You’re installing the wrong package name / wrong PHP version&lt;/strong&gt; for your Ubuntu release.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A config file references a path or module that doesn’t exist&lt;/strong&gt; (common with Apache ↔ PHP module mismatches).
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the goal isn’t to guess. The goal is to restore your system to a clean package state, install the right components, and verify services.&lt;/p&gt;

&lt;h2&gt;
  
  
  The “fix it first” command block (most common solution)
&lt;/h2&gt;

&lt;p&gt;If you want the shortest path to “working LAMP,” run this sequence first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;--configure&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;apache2 mysql-server php libapache2-mod-php php-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This matches the “repair apt/dpkg, then install core LAMP packages” approach from the SudoGuide article. &lt;/p&gt;

&lt;p&gt;If the install completes cleanly, skip down to &lt;strong&gt;Verification&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 0: Confirm your Ubuntu version (matters more than you think)
&lt;/h2&gt;

&lt;p&gt;Package availability—especially PHP versions—depends on your Ubuntu release. Confirm it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsb_release &lt;span class="nt"&gt;-ds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why this matters: people often follow a tutorial targeting a different Ubuntu version and end up installing packages that don’t exist (or mixing PHP versions/modules). The SudoGuide article calls this out as a common cause of “missing file/module” style failures. &lt;/p&gt;

&lt;h2&gt;
  
  
  Error pattern 1: “Unable to locate package” / missing packages
&lt;/h2&gt;

&lt;p&gt;If you see errors like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;E: Unable to locate package ...&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;packages that &lt;em&gt;should&lt;/em&gt; exist “can’t be found”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do this:&lt;/p&gt;

&lt;p&gt;1) Update package lists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) If &lt;code&gt;apt update&lt;/code&gt; shows repository errors, fix/disable the broken repo lines before retrying (this is a frequent underlying cause of “packages can’t be found”). &lt;/p&gt;

&lt;p&gt;Then rerun the install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;apache2 mysql-server php libapache2-mod-php php-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Error pattern 2: “dpkg was interrupted” / broken package state
&lt;/h2&gt;

&lt;p&gt;If you see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dpkg was interrupted, you must manually run 'sudo dpkg --configure -a'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;dependency/configuration errors that won’t go away&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repair your package manager state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;--configure&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then retry installing the stack. This exact dpkg repair workflow is a central part of the SudoGuide troubleshooting path. &lt;/p&gt;

&lt;h2&gt;
  
  
  Error pattern 3: &lt;code&gt;command not found&lt;/code&gt; (but the tutorial says it should exist)
&lt;/h2&gt;

&lt;p&gt;This one is sneaky because it looks like your shell is broken, but it’s usually just “that package/tool isn’t installed yet.”&lt;/p&gt;

&lt;p&gt;Two common cases:&lt;/p&gt;

&lt;h3&gt;
  
  
  A) &lt;code&gt;add-apt-repository: command not found&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Install the helper package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;software-properties-common
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SudoGuide specifically flags missing prerequisites like &lt;code&gt;add-apt-repository&lt;/code&gt; as a reason installs derail. &lt;/p&gt;

&lt;h3&gt;
  
  
  B) MySQL hardening command missing
&lt;/h3&gt;

&lt;p&gt;If &lt;code&gt;mysql_secure_installation&lt;/code&gt; is missing, it often means MySQL server itself isn’t installed correctly yet. Make sure you installed the server package successfully first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;mysql-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(That “secure installation” step is widely recommended in standard LAMP setups.) &lt;/p&gt;

&lt;h2&gt;
  
  
  Error pattern 4: Apache won’t start (often PHP module mismatch)
&lt;/h2&gt;

&lt;p&gt;A classic scenario:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apache installs fine&lt;/li&gt;
&lt;li&gt;You install PHP&lt;/li&gt;
&lt;li&gt;Restart Apache and it fails&lt;/li&gt;
&lt;li&gt;Logs/config mention missing &lt;code&gt;.so&lt;/code&gt; modules or paths&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The underlying cause is often: &lt;strong&gt;Apache is configured to load a PHP module that isn’t actually installed&lt;/strong&gt; (or you have version conflicts). The SudoGuide article highlights “wrong paths/modules in config” as a frequent reason for “file not found” style errors during LAMP setup. &lt;/p&gt;

&lt;p&gt;Start with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apache2ctl configtest
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status apache2 &lt;span class="nt"&gt;--no-pager&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then ensure the Apache PHP module package is installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;libapache2-mod-php
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(If you’re juggling multiple PHP versions, you may also need to disable one module and enable another, but don’t do that unless you know you’re in a multi-version situation.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Error pattern 5: “Permission denied” (install or web root)
&lt;/h2&gt;

&lt;p&gt;Two common permission issues:&lt;/p&gt;

&lt;h3&gt;
  
  
  A) Installing without sudo
&lt;/h3&gt;

&lt;p&gt;If you see permission errors during install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  B) Writing files into &lt;code&gt;/var/www/html&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Ubuntu’s default web root is typically owned by &lt;code&gt;root&lt;/code&gt;. If you’re testing with a quick PHP file, write it with sudo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;?php phpinfo(); ?&amp;gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /var/www/html/info.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Error pattern 6: “Bad file descriptor” / weird I/O errors
&lt;/h2&gt;

&lt;p&gt;This is often not “a LAMP problem” at all—it’s a system problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;low disk space&lt;/li&gt;
&lt;li&gt;corrupted package downloads&lt;/li&gt;
&lt;li&gt;filesystem issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SudoGuide frames this as a separate class of failures and recommends system-level checks (disk space, cleanup, reinstall). &lt;/p&gt;

&lt;p&gt;At minimum, check disk usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re critically low, free space and retry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verification (make sure the whole stack is actually working)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1) Apache is running
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status apache2 &lt;span class="nt"&gt;--no-pager&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also test locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-I&lt;/span&gt; http://localhost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2) PHP works via Apache
&lt;/h3&gt;

&lt;p&gt;Create a test file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;?php phpinfo(); ?&amp;gt;"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /var/www/html/info.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;http://YOUR_SERVER_IP/info.php&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; remove it immediately after testing. Leaving &lt;code&gt;phpinfo()&lt;/code&gt; exposed can leak configuration details (extensions, paths, environment info) you don’t want public. &lt;/p&gt;

&lt;p&gt;Remove it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo rm&lt;/span&gt; /var/www/html/info.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3) MySQL is alive
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status mysql &lt;span class="nt"&gt;--no-pager&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Debugging checklist (when you’re still stuck)
&lt;/h2&gt;

&lt;p&gt;If something still fails, don’t reinstall blindly—collect signals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repair package state:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sudo dpkg --configure -a&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sudo apt install -f&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Validate Apache config:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sudo apache2ctl configtest&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Check logs:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sudo journalctl -u apache2 -n 100 --no-pager&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sudo journalctl -u mysql -n 100 --no-pager&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern to remember: LAMP “file not found” errors are usually either &lt;strong&gt;package manager state&lt;/strong&gt; (apt/dpkg) or &lt;strong&gt;module/config mismatch&lt;/strong&gt; (Apache/PHP). &lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thoughts
&lt;/h2&gt;

&lt;p&gt;Most LAMP install failures are fixable without nuking your server. Treat the error message as a hint, restore your package manager to a healthy state, install the core packages for &lt;em&gt;your&lt;/em&gt; Ubuntu release, then verify each layer (Apache → PHP → MySQL).&lt;/p&gt;

&lt;p&gt;Source inspiration: SudoGuide’s troubleshooting walkthrough on LAMP install errors for Ubuntu. &lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>php</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
