How to use bind to work with applications like FileZilla without modifying the LAMP installation.

Introduction.

We need to add a permanet link between both folders to be able to work locally with FileZilla and other editors without changing the Apache configuration because some applications needs root permisions. This is the most reliable solution.




We have Ubuntu 22 with Apache installed.

We will a Bind, in this case my user linux names "benjamin" you can change for yours. 

Create folders (if they don't exist).

  
    sudo mkdir -p /home/benjamin/www/html
    

Important, All file from /var/www/html will be hidden make backup before next step.

Mount bindbind

From this point on, FileZilla writes to /home/benjamin/www/html and Apache reads the exact same files from /var/www/html. No duplication, no scripts, no cron, instant changes.

  
   sudo mount --bind /home/benjamin/www/html /var/www/html
    

But this change is not permanent, for this reason you need set next configuration for permit maintain this mount folder.

Make it permanent

Very carrefully this step could to damage your linux. 

  
   sudo nano /etc/fstab
    



Image of example.

Add just one line to the end of file. Very important use the same spaces between characters.

  
 /home/benjamin/www/html  /var/www/html  none  bind  0  0
    

Save the file /etc/fstab

Test using command. 


  
    sudo mount -a
    

If there are no errors, it's all correct.


Add or check his correct permissions. 


  
   sudo chown -R benjamin:www-data /home/benjamin/www
   sudo chmod -R 755 /home/benjamin/www
    

Now you can restart and test writing a file on /home/benjamin/www you should see the same file in /var/www/html




















Comments