Advice on setting up a web development environment on linux

I switched to Linux about 4 years ago, and I really don’t want to ever see another Windows system again. Prior to that I usually had 2 or 3 programming projects going at any one time. But since switching I haven’t hardly touched any code, maybe one little project, that I gave up on. The big hangup is getting my environment setup, it is insanely cumbersome and most of the time I don’t get it working.

There is got to be something I am not aware of. I just need a quick web server running on my local PC. I would really like PHPMyAdmin as it saves a ton of time in configuring and managing MySQL databases, and its the tool all the web hosting companies include. I need to be able to easily setup new custom URL’s (my.new.project) that can be pointed to any directory I choose. And as I have been know to crash web servers a very fast way to shutdown and restart the entire web server.

Use docker. Set up a docker-compose.yml file for your project with a shared volume to your project and configure the docker container to run your code in there. That’s arguably the most efficient way to run dev envs without cluttering your own machine with stuff. Easy to just destroy everything and start over if you need to.

EDIT: Oh yeah, and the networking part. Since docker containers can have IP addresses, you can just add entries to your /etc/hosts file to give them domain names. I never had a need for something more complex, I guess it will fulfil the requirements for you also.

1 Like

you might also spin up a vm and treat it like a dedicated server

configure ftp, all the routing and shit and push to it

that would also give you XP

Docker seems like ton of work for no real benefit. And you have to do that for every project?

Previously, when starting a new project, I would just edit the “hosts” file then using AMPPS point the URL to the folder I wished to use. If timed I could probably do it in under 30 seconds. Docker just adds layers of complexity that is not needed. And what is most aggravating is I can guarantee in a year, or so, when I start a new project I will NOT remember how to do it, and not be able to find the relevant instructions.

I guess if I were to break it down I am looking for just a few of the tools that came in the AMPPS package.

Hi ShaneH

A couple of thoughts depending on what you are trying to do:

  • to answer your first question of an easy way to get a web server setup on your linux machine: The apache web server is a go to. It is in most repositories that ship with most distro’s. It’s easy to install if it isn’t on your distro already (and can be started with service/systemctl/init/cron…)
  • You can use containers (as mentioned before hand) Docker and Kubernetics are the go to ones. They offer a lot of functionality while being light on resources (no duplicate processes). They have images that can cover a lot of sets/configs, so if you want [apache 2.4 with php 5.1] you can build that image and just open and run that static image, delete that instance and go again.
  • You can use VM’s, Virtualbox and VMware Workstation are kind of go to desktop ones (You can also do bare metal with Microsoft hypervisor and VMware ESXi). You can create a VM image [like Ubuntu server] and just spin up copies, delete the copies, and run how you want. Because these are full OS’s you can also configure everything instide the way you want and have images named after it. This can include your apps installed and configured [example 1 - Ubuntu server, with apache installed, ip set to 192.168.0.1, database calls to other address like 192.168.0.10. Example 2 - Ubuntu server with database installed, already configured and running, IP of 192.168.0.10]. Virtual machine tools allow you to segregate the network too.

So a bunch of options and flexability.

php -S localhost:8080

Works as a quick and dirty dev server, but maybe you need access to it from other devices, or the project isn’t written in PHP(although there are similar things for other languages). In those cases you’re better off with apache/nginx/caddy or a dockerized setup that allows for a more complete environment.

If you want to be a full stack developer, then you need to be comfortable working with the environment. If that’s a constant problem and you end up hating it, and you have the opportunity, then do yourself a favor and stick to the frontend only.

For databases and such things that kinda live around the project that I don´t write, I also usually run them now in docker containers and just slap in a docker-compose file into my projects that sets up all that stuff.

But for the program I´m actually writing there is always some kind of dev server built in and imo in most cases that´s the prefered option. In developement you care more about compile/transpile speed and debugability than you do about minimizing network traffic, maximizing security and having it be “equal to prod”.

A lot of things done in production environments are just not feasable, not possible (cloud cough cough), or counter productive in other ways to duplicate on a local dev machine to develope that way.

I tried once (x years ago, forgot) to do that too with vagrant. But I dont really actually see it done anywhere. Plus it was just straight up more work than not doing that. Personally, I didnt see a benefit. It just took time to setup and took time to startup and ate RAM for no reason.
Unless, you need to develope things that inherently depend on a very specific setup. There is really no point to go threw that. Web development can be very platform dependent if say you develope something that manages Linux servers, or something that is very old and there is no way to install it without virtualization. But most web development with the tools we have today absolutely does not care where its being run on.

https://docs.openstack.org/devstack/latest/

Run your own cloud. Be your own devops team. Write your app.

Become a one man army.