Background
If you're used to using Laragon on Windows, you've probably been spoiled by its auto virtual host feature. It allows you to access your projects using a custom domain instead of typinglocalhost/project_name. For example, if you have a project named "akubagi", and you place its directory inside Laragon’s web root, Laragon will automatically create a virtual host with the address "akubagi.test".That’s actually what pushed me to switch to Linux. Luckily, I came from macOS, so I wasn’t completely clueless—both systems are Unix-based after all.
akubagi.test had to be accessible as https://akubagi.test.Prerequisites
Everything you need is actually super simple. You only need:
- PHP
- Apache
- Mkcert
I won’t go into the installation process here, but as long as you can get phpinfo(); to show up in your browser, that means everything is set up correctly. Apache2 acts as the web server, and mkcert is used to generate local SSL certificates—so you don’t have to deal with the hassle of using OpenSSL manually.
Step by Step
/var/www—makes things easier, especially since that’s how it’s done on our office server. Next, you can clone your favorite project and move it into /var/www. You’ll probably need permission for that, so make sure to use sudo when moving the files. I’m just gonna assume you already know the drill when it comes to stuff like this.Next, you can create your virtual host configuration like this:
And here’s the content of the virtual host file—you can adjust the paths as needed, just make sure to be careful and double-check everything.
Once that’s done, you can generate the SSL certificate. Make sure the path matches whatever you declared in your virtual host file. As for me, I usually keep all my certs in ~/Projects/certs, so I can collect all certificates from my various projects in one place. I just don’t feel like initializing them in each project’s root directory—it’s kinda annoying, hahaha.
Generate certificate is simple, just use command mkcert your-project.test
And then you must add one line below your /etc/hosts file like 127.0.0.1 your-site.test
After that, you need to enable the module and activate the site from the virtual host you just created using the commands below:
Now, here comes the permission part—again.
Why permissions again?
Because without fixing this, you won’t be able to open or edit your code properly in VSCode.
So, what we’re gonna do here is use ACL to give your Linux user the right permissions, so you can edit your code freely without running into those annoying permission issues.
Here’s how to do it:
Closing Statement
I think this method might feel a bit tricky for those who aren’t familiar with it, but once you get the hang of it, it’s actually super easy. With this setup, you can access your project in the browser using the pretty URL we configured earlier. If you know a more efficient way, feel free to let me know.
Hope this was helpful for you—and it also serves as a personal note for me, because this stuff is pretty important in my workflow.
Thanks a lot for reading!
If you found this useful, feel free to share it with your friends.
See you next time!


0 komentar:
Posting Komentar