Ubuntu Server with GUI

I am sure you already know the security and performance concerns about having a GUI for your Ubuntu server; for any Linux server actually. You are strongly recommended against it. If this is the first time you hear about this, then it is time for you to start googling and do some reading to learn why and how serious the recommendation is.

But you might have your own reasons for needing a GUI for your server (valid or not). After working with Windows for more than a decade, both on the server and the client side (and I am still a windows guy on the client side), I was having hard times to manage a Ubuntu server through a command line when I first started. I just went ahead and installed a GUI on my server, even worse it was a production server. I don’t do that anymore, unless it is a virtual machine on my laptop to test some stuff. But the truth is, it helped me to learn about managing an Ubuntu server. I know while it helped me to perform some tasks faster it probably slowed down my learning process but sure it made me to stick with Ubuntu and learn it.

Well, that being said, if your reason is merely a simpler and faster server management, I do not recommend it and I am not doing it myself anymore.

Now for a light weight desktop environment, Lubuntu is the way to go. There are even some lighter alternatives like Openbox and Fluxbox but they are not as user friendly as Lubuntu. I tried them and inmy case they were killing the idea of having a GUI in the first place. Your case might be different and you might wanna give them a try if you like.

If you install the “lubuntu-desktop” package you can have a full blown Lubuntu desktop but I am sure you wouldn’t want a complete desktop environment. You might try the “lubuntu-core” package which comes with limited applications. Now let’s take it one step further and add the “–no-install-recommends” parameter to the command so it comes with a couple of terminal applications and with a file manager. You can install the missing applications that you need later on.

Install Minimal Lubuntu Desktop

apt-get install lubuntu-core --no-install-recommends

After rebooting the server you should be able to login to your server through the Lubuntu desktop gui. You will notice that all you got is a file manager, 3 different terminal applications and the Desktop Preferences entry in your menu.

Install Some Essential Software

Now let’s install some applications so the desktop becomes usable. Add or remove according to your needs but this is what works me, not too much not too little.
leafpad: Text editor.
lxterminal: A better terminal application, since all the 3 comes with lubuntu-core installation sucks.
file-roller: An archive manager to help with compressing & extracting files, archives. If your not good with tar.
lxrandr: Monitor Settings GUI to change resolution easier.
synaptic: Synaptic Package Manager
firefox: Browser but I prefer Google Chrome myself. Don’t install it if you want to go ahead with Chrome.

apt-get install leafpad lxterminal file-roller lxrandr synaptic firefox

Install Google Chrome from Command Line (terminal)

If you want to install Google Chrome as your browser.
1. First install the key from Google Linux Repository.

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

2. Then add it to your repository list

sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'

3. Update your sources.

apt-get update

4. Install Google Chrome

 apt-get install google-chrome-stable 

Run Google Chrome as Root

Now if you are managing your server with the “root” user rather than going through “sudo” and “su” commands then you will have problems to run Google Chrome as root. Here is how to fix it. This method seems to be more permanent among others.
1. Open “google-chrome” file located in “/usr/bin” with your text editor (leafpad).

leafpad /usr/bin/google-chrome

2. Add ” –user-data-dir” (without the quotes and with leading space) at the very end of the file.
When you finish, the last line of the file should look like this…

exec -a "$0" "$HERE/chrome" "$@" --user-data-dir

3. Save the file and close. You are done.

Boot into Text Mode & Use startx for GUI

You also might want to run your server on the text mode, the command line by default and load the GUI when you need it then turn back to the command line when you are done and logged out.

First change the run level so the server always boots into command line.
Edit file…


This line…


Should read…


Make the changes, save the file then update grub with the command…


Now create the file “.xsession” in your home folder.

touch ~/.xsession

with containing the text below…

lxsession -s Lubuntu -e LXDE

Now reboot your server. It should boot into the command line and login.


will take you to the Lubuntu desktop environment, already logged in.
Logout after you are done and you are back to the command line again.

When using an Headless Server, a VPS…

If you are using a VPS (headless server) things will change a little, not too much.
Start with installing the Lubuntu desktop.

apt-get install lubuntu-core --no-install-recommends

Now you need a way to remotely connect to your desktop. For this there are different approaches and each approach have different alternatives. Like 4 years ago, I have spent quite sometime reading about most and tested some of them. I find NX based solutions to be the most efficient.

At the time Nomachine’s NX server/client was fast, lightweight and easy to install, manage and use for me. It was version 3.x. Recently they released a new version 4.x and to my experience this new version fails on all fronts. Maybe I just failed to configure the new version properly but if that’s the case then it is another proof that it is not as user friendly as it was before. So, I decided to move away from Nomachine’s solution.

Well, this time I haven’t spent that much time to investigate the alternatives but a quick search led me to x2go software, which also uses NX Technology and seems to have more features. Free and open source, while Nomachine is free it is not open source. As far as my limited usage, it is just a better replacement.

So, let’s install x2go on the server….
1- Install required package.
2- x2go repository.
3- Update your sources.
4- Install x2go components.

apt-get install python-software-properties
add-apt-repository ppa:x2go/stable
apt-get update
apt-get install x2goserver x2goserver-xsession x2golxdebindings

Now you know that I am using the “root” user to manage my server and I need to have ssh access for my root user. By default Ubuntu 14.04 restrict ssh for root access to key authentication (passwordless). As far as I can remember, this was not the case with 12.04. For the sake of this guide, I will configure ssh so I can authenticate my root user with regular username/password. This may not be a good idea where security concerns are high. I will write about how to use key authentication for root user with some different client software, including x2go, in another post.

Edit your “sshd_config” file…


Find and change the line below…

PermitRootLogin without-password

It should read like this…

PermitRootLogin yes

Restart the ssh service…

service ssh start

Now go ahead and install the x2go client and create a new session. All setting should be straight forward, except one.
Session type should be “Custom desktop” and required command should read…

lxsession -s Lubuntu -e LXDE

…startx will not work here.



You should be able to remotely connect your VPS Server’s GUI.

Now you can install some essential software.

And since you are using an headless and/or VPS Server, it is more important that server boots into text mode by default and GUI is only loaded when needed. Just follow the first part of “Boot into Text Mode & Use startx for GUI” section. You don’t need the second part since “startx” will not work with x2go connections.

Tagged with: , , , ,
Posted in Ubuntu

Update Manager with SSH

This gonna be short and sweet.

If you need/want the Drupal Update Manager to work through SSH then you need to install the “libssh2-php” php package on your Ubuntu server. You know the Update Manager; it’s the admin interface when you install a module or theme, or more importantly if you are doing system-wide updates.
Update Manager

If you do not have the “libssh2-php” package installed then the only option you will have is FTP.
FTP Only

Unless you have a very specific reason, you do not want to run an FTP server on your Ubuntu server. Especially, when you have alternatives like SFTP and SCP for transferring files and they are based on SSH.

Now to enable the SSH option on the Update Manager page, you need to install the “libssh2-php” package and reload your apache server.

apt-get install libssh2-php
service apache2 reload

Now you have the SSH option on the same page.
SSH Option

Well, that being said, using Drush would be a better choice for these operations but there might be times where you need this.

Tagged with: , , ,
Posted in Drupal, Php 5.5, Ubuntu

Delete Default Site

When I got my first VPS (from Linode) like 4 years ago, for heavy Drupal use, I read a lot of guides about setting up a LAMP stack on Ubuntu. At first most of those guides I read and followed were Drupal specific but later on I read a lot of non-drupal, LAMP stack related stuff as well.

In addition to the guides I read (and still reading), now I have 4 years of experience and knowledge that I learned by trial & error. Not to mention that I have a long System Admin (Windows only) and Database Admin (mostly Oracle) past. I still wouldn’t call myself a full-blown Linux System Admin but I believe I have come quite a long way since then.

Now I am thinking about the guides and wondering why none of the ones I read does not tell people to delete the default site configuration that comes enabled upon Apache installation. As if this is not enough, almost all of them relies on making changes on that default site config (Drupal or not).

99 times out of 100, you do not want/need a default site running on your server; which will service to any request that finds your server via IP or DNS; unless the request belongs to a website that you specifically configured. And I am sure you don’t want your apache to service a request, let’s say, http://imap.example.com unless you specifically configured a site for imap.example.com.

One of the first things I do is to delete that default website.
I can either delete the symlink…

cd /etc/apache2/sites-enabled/
rm 000-default.conf
service apache2 reload

or you can do it by disabling the site with “a2dissite” command. Some might say that this is the proper way to do it but actually they do the same thing; removes the symlink.

a2dissite 000-default.conf
service apache2 reload

As you have noticed that I did not actually delete the default site configuration file which resides in “/etc/apache2/sites-available/” I have only disabled that site. Who knows, I might need that file in the future (for reference purposes most likely).

Now the question pops in mind; the guides you follow tells you to make a change in that default site config file. Of course the changes will not have any effect since the default site is disabled. As for Drupal, it will ask you to change “AllowOverride None” to “AllowOverride All” in the below shown block.

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

This is how you do it. Open your “apache2.conf” file, where your real defaults are set. Find the same block and make the same change there.

cd /etc/apache2/
vi apache2.conf
##  Make the changes  ##
service apache2 reload

This is on Ubuntu 14.04 …

Tagged with: ,
Posted in Apache 2.4, Drupal, Ubuntu

Disable OPcache Per Site

If you have upgraded (or planning an upgrade) your Drupal 7 platform to Ubuntu 14.04 then you most likely know about the “install creates 31 tables then stops” and “Installation failure when opcode cache is enabled” issues. Which is caused by a problem between the Drupal code and OPcache.

A few words about the OPcache. Ubuntu 14.04 comes with php 5.5, which has Zend OPcache built-in. If you have already tried to install APC extension for your php setup, you failed. And if you googled about this failure then you heard that the APC is included in php5.5. Well, you can say that. Actually, the type of these caching solutions are called “OpCode Cache“. “APC” is one of them. “Zend OPcache” is another one; and this Zend OPcache (or OPcache for short) is built into php 5.5, not APC.

The Drupal problem has been fixed for D8 on this issue but no patch is available for D7 yet.

The workaround is to disable the OPcache, which is enabled by default. It is a setting in php.ini file.


The question has been raised if disabling the OPcache before installation and enabling it right after would be good enough. While I don’t have a solid answer for that, it should be good enough to keep it disabled during installation and upgrades. I permanately turned it off on my test site. Maybe I should turn it on again and do some tests..

Another question I have seen but not answered was, if we can disable the OPcache per site basis. Like disabling it for a D7 sites and enabling it for others.

Yes, we can do that. As the title of this article suggests, we can disable OPcache per site basis but we cannot enable it whenever we want it; it should be enabled by default. If you have disabled it through php.ini file, then you need to revert it back.

Placing below line in your “settings.php” file will disable it.

ini_set('opcache.enable', '0');

However, I like the “.htaccess” method much better.

php_flag opcache.enable Off

Remember that your apache config should have “AllowOverride All” in order to make the .htaccess method work; which is also a requirement for installing & running Drupal websites.

Tagged with: , ,
Posted in Drupal, Php 5.5, Ubuntu

How I met php5enmod ?

I am sure most of you already aware of the command but I have just learned about it recently, while I was playing with Ubuntu 14.04. After installing php modules, some are not enabled by default upon installation. One of those modules is php5-imap and php5-mcrypt is another one. You have to enable them with php5enmod command. As far as I can remember, this is not the way it used to work with Ubuntu 12.04.

php5enmod works just like the way a2enmod works for Apache.

php5enmod module-name     # to enable php module
php5enmod imap            # to enable php5-imap
php5enmod mcrypt          # to enable php5-mcrypt

…or php5dismod, just like a2dismod works.

php5dismod module-name     # to disable php module
php5dismod imap            # to disable php5-imap
php5dismod mcrypt          # to disable php5-mcrypt

You can always see the enabled php modules with…

php -m                 # for the entire list
php -m | grep imap     # to check for a certain module name

Do not forget that, even if you see the module name enabled on the “php -m” list, the module will not be active and working until you reload/restart apache. I am sure you know the difference between reload and restart; restart shuts the service down and then starts it up again, whereas reload instructs the daemon to reload its configuration.

service apache2 reload

Hope this helps someone…

Tagged with:
Posted in Php 5.5, Ubuntu