Creating a Simple Multiple Programmers Environment on Development Web Server

While it's obvious that we should use git to manage the programmer's source codes on production servers, but TBH it's kinda annoying on the development servers.

Some of our programmers also haven't learned git yet, using only the traditional way of SSH and SCP-ing the source code to the server.

But this is kinda a problem for the sysadmin. SSH access meaning they can easily access the other programmer's code, even maybe deleting it or changing it without concern. We should make it better.

 

Separating the user

I use Debian 10, Apache2, and PHP here. It is obvious that we should give one credential per programmer.  So the code is isolated to them.

First as root, create the user using the using adduser command and specify the home directory to the directory that can be accessed by Apache2. On this post, I created abc user using home directory of /var/www/abc:

We need to add Apache2's user to this user group so it can have the same group privilege (like reading or writing the code). The default user for Apache2 on Debian 10 is www-data, so:

Then create a directory inside the home folder and put the simple PHP script inside them, so we can access it later (at this example, it will be on http://<server's IP>/web):

Repeat all above steps for all the programmers. There we go, we have a separated credential and home directory for each programmers that they can put their source code and can't be seen by other programmers.


Configuration on Apache2

The next step is to tell Apache2 which directory it should serve, when the URL match.

if there are 2 'web' apps -- one created by 'abc' and the other by 'def' -- then how can Apache2 differentiate between it should go to abc's code or def's code? Yes it is not possible, so the programmer should know first that their name of the apps should be unique.

Note: I won't use the AliasMatch feature because we need to change a lot of default configuration from Debian's Apache2. So I will use the symlink feature.

Make a symlink to the abc's code:

Then don't forget to protect other programmer's (for example, def's) and Apache2's root directory:

Voila, the http://<server's IP>/web will be serving the abc's code in the /var/www/abc/web