Preparing the Raspberry Pi to act as a server

By | 17 June 2018

As you already know, the Raspberry Pi is a wonderful nano-computer with a lot of features. By default, the Raspbian OS is configured to be used as a desktop computer. But it’s better used like a server! To do that, we need to perform some cleanup (i.e. removing useless packages) and add some additional packages to convert our Pi into a real server!

Setting a static IP

Before starting, you should have set a local static IP. Click here to learn how.

If you have a dynamic IP address from your ISP, you should use No-IP or something similar in order to access the Pi from anywhere. Click here to learn how.

Removing useless packages

The commands below removes all desktop useless packages.

After that, we have a more lighter Raspbian OS.

Updating the Pi

Now it’s time to update your Pi, to be sure you use the latest packages.

Enter the following:

If you want, you can upgrade the distribution if you have installed your Pi long time ago:

Then, you can update the Pi firmware too:

Then to finish the update, your reboot the Pi:

Creating an update script

It’s a good idea to create a shell script to execute these commands regularly:

The copy the following in that script:

Then hit CTRL + X  and Y  to save.

Make it executable:

And now, you can execute it by :

Or you can use cron to execute it regularly automatically if you want, but I dislike this since I want to check the compatibility before doing anything!

Installing xRDP (Optional)

xRDP is a great package to access the Raspberry Pi throught RDP, which is the Microsoft‘s technology to use a computer remotely. Of course this is useful if your daily computer is Windows-based! In that case, you should run the mstsc executable. If you have an Unix system like Ubuntu or MacOS X, you can use Remmina (which is a RDP client) or just stick with SSH (which is enabled by default in Raspbian)!

To install it, follow this guide, or follow the steps summarized below.

The first thing to do is to disable the RealVNC client that comes installed with the latest Raspbian image because it causes some problems to xRDP.

Enter the following command:

Choose the  5 Interfacing Options option, then P3 VNC . Disable it when asked. After that, install the xRDP package:

Finalize by solving the ‘X’ cursor problem:

Now your Raspberry Pi can be accessed by xRDP.

Done!

So now you have a clean and ready Pi to be used as a server! 🙂

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.