Search code examples
serverlampwindows-subsystem-for-linux

What is the best way to setup lamp in wsl, and where should i put codes that easy for atom to edit


I am a developer that used windows 10 and all my tools are installed in windows 10 such as atom, laragon, gitbash.

here's the scenario, since I am using laragon as a server on windows 10, I put all my codes in c:/laragon/www. so that when i visit my website at localhost, codes found in www is located and serve to localhost.

now i try wsl on windows, when i installed lamp, my code should reside in /var/www/. the problem with this i can't use atom which is installed in windows to edit code found in /var/www.

my question is, since i been looking for good article at google that best discuss to setup php development using wsl.

What is the best way to setup lamp in wsl, and where should i put codes that easy for atom to edit.

sorry if i don't know this, because i really don't know, and i been looking for this for almost a month now.


Solution

  • I would highly advise against doing this.

    Use WSL to mount C:\laragon\www and edit the files within the windows filesystem using atom but even then, it may be best to just completely use the windows environment.

    Microsoft have issued warnings that you can edit windows files from inside WSL, but should not under any circumstances edit WSL/files within the ubuntu underlying filesystem from windows [1].

    Speaking from experience on trying to set up web services, be it a MERN stack, meteor or a LAMP stack on WSL, I have also had a lot of issues with permissions on starting database services.

    1 : https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/


    Steps to hosting LAMP in WSL with the files to be served in windows to be edited by windows tools;

    1. Mount a windows directory (If you haven't already)
    2. Update your Apache / LAMP stack configs to point at the mounted directory; See this article for some good info. https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-16-04
    3. Restart Apache and if needed, other LAMP related services. (The above article covers this as the last step anyway)