Traditionally we developers build software on their desktop machine to test it on a webserver. In an earlier post we concluded that the main advantages of developing on Linux is that you can reliably test and debug your application on your local machine. In this post we are going one step further: we move the desktop with its development tools to the cloud with NX based software called “x2go” and we setup this system to be multi-user.
The advantages of a multi-user desktop development environment is that you have less environments to install, secure and manage versions (like updates). Also you can easily update/modify each others projects when large refactoring is being done. Another advantage could be that cooperation (using screen sharing or file exchange) is easier. Disadvantages include difficulty to experiment with different software versions. Also, there is the need for a more formal (better organized) process around installing and configuring software. This could also be a good thing, because it enables companies to keep the focus on a specific set of programming languages and development tools.
If you want a fast multi-user linux machine I recommend buying a good quad or hexacore machine with a pair of SSD drives (in raid-1 configuration). After that you should install a fast but common distribution (like Xubuntu 12.04) and the “x2go” software. If you want to be able to easily clone the machine you might want to run this machine on a KVM hypervisor (as a virtual machine). Especially when doing distribution upgrades it might be a good idea to make a clone and/or snapshot, because breaking the desktop environment of multiple developers might be an expensive mistake.
Quick howto to turn your machine into an X2Go server:
sudo apt-add-repository ppa:x2go/stable sudo apt-get update sudo apt-get install x2goserver
Create a session startup script:
sudo nano /usr/local/bin/xfce2go.sh
That contains the following content:
#!/bin/bash nxnode=$(ps -o ppid= -p $PPID) nxagent=$(pgrep -P $nxnode -u $USER -x nxagent) export XDG_DATA_DIRS="/usr/share/xubuntu:/usr/share/xubuntu:/usr/local/share/:/usr/share/:/usr/share" export XDG_CONFIG_DIRS="/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg" export XDG_MENU_PREFIX="xfce-" /usr/bin/startxfce4 exec kill $nxagent
Quick howto to install the x2goclient:
sudo apt-add-repository ppa:x2go/stable sudo apt-get update sudo apt-get install x2goclient
In the “Session” tab in the “Session type” drop down box choose “Custom desktop” and enter the command “/usr/local/bin/xfce2go.sh”
Now we are able to run Xubuntu remote from Microsoft Windows or Apple OSX (or Linux).
Next instructions are to make sure Apache webserver and alls users can read and write each others data. This is done by changing the “umaks”. The umaks influences what file rights files get when created by a user. By default directories are created with 755 permissions and files with 644 permissions. This is because the default umask is 022. If you change the default umask to 002 directories and files become writable for the group the users are in (all users that have the same primary group). If we then change all users to have the same primary group we can read and write each others files.
First we make sure Apache webserver runs with the “users” group.
sudo nano /etc/apache2/envvars
Make sure it contains the following values:
export APACHE_RUN_USER=www-data export APACHE_RUN_GROUP=users
Add the following line at the end of the file
Now to change the “/var/www” directory to be editable by all users run:
cd /var/www chgrp -R users . find . -type f -print0 | xargs -0 chmod 664 find . -type d -print0 | xargs -0 chmod 775
Now Apache is configured to run with the correct group and the correct umask. Now we have to do the same for the users.
To set the primary group for user “maurits” is the “users” group, execute:
sudo usermod -g users maurits
To set the default umask for all users, execute:
sudo nano /etc/login.defs
Add the following line at the end of the file:
Now to change the home directory of the current user to be editable by all users run:
cd ~ chgrp -R users . find . -type f -print0 | xargs -0 chmod 664 find . -type d -print0 | xargs -0 chmod 775
That is it, not too hard right? If you are also building a setup with x2go, please share your experience!