I have just installed a new Debian Linux server, this will be running mainly as a web server without a GUI and console access will be via an SSH login, some knowledge of using Linux is assumed as these notes are intended as a prompt or overview of things to do to as part of a Linux server installation.
I am using Debian version 11.2 – Bullseye, the current version at time of writing, but these notes should work with any distribution that uses the apt package manager like Ubuntu. The ISO image used for installation came from https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/ and I have used the Xfce install: debian-live-11.2.0-amd64-xfce.iso (2.4G download). A guide for installing the Debian image can be found on this TecAdmin page.
At the Console
Your computer is now inviting you to login, do so with your local user and once the default desktop has been created open a terminal window to complete the following; switch to the root user and add your local user to the sudoers group:
1 2 3 |
$ su <root password> # /sbin/usermod -aG sudo <username> |
Now logout and back in, this updates your user account settings, and go back to the terminal to update the system, install ssh access and a couple of useful tools, and finally set the computer to boot to console rather than the GUI:
1 2 3 4 |
$ sudo apt update $ sudo apt upgrade $ sudo apt install openssh-server wget curl $ sudo systemctl set-default multi-user.target |
If you have installed into a virtual machine now is a good time to install the guest client, links to popular VM’s:
- VMware: https://kb.vmware.com/s/article/1018414
- Oracle Vbox: https://linoxide.com/how-to-install-virtualbox-gue…
- Synology Virtual Machine Manager: https://kb.synology.com/en-uk/DSM/tutorial/How_to_install_Synology…. (at the bottom of the page)
- $ sudo apt install qemu-guest-agent
Finding your IP address is useful:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 02:11:32:23:83:6c brd ff:ff:ff:ff:ff:ff altname enp0s3 inet 192.168.1.20/24 brd 192.168.1.255 scope global dynamic noprefixroute ens3 valid_lft 86253sec preferred_lft 86253sec inet6 fe80::11:32ff:fe23:836c/64 scope link noprefixroute valid_lft forever preferred_lft forever |
In this instance it is 192.168.1.20. For a server I would normally fix the IP address in my router as a Reserved Address using the MAC (in this case: 02:11:32:23:83:6c).
Removing libreoffice clears a useful amount of diskspace:
1 2 |
$ sudo apt remove libreoffice* $ sudo apt autoremove |
Restart with $ sudo reboot You can now login via SSH from your other computer or continue at the console.
Installing the LAMP service – MySql, Apache and PHP
Start with MySql (MariaDB being the open source version), installing, configuring and starting:
1 2 3 4 |
$ sudo apt install mariadb-server $ sudo mysql_secure_installation $ sudo systemctl enable mariadb.service $ sudo systemctl start mariadb.service |
For the secure installation, use the defaults and set the password when prompted. Next is Apache and PHP:
1 2 3 |
$ sudo apt install apache2 php libapache2-mod-php php-gd php-mysql php-mbstring php-xml $ sudo systemctl enable apache2.service $ sudo systemctl start apache2.service |
Point your web browser to the server address, in my case: http://192.168.1.20, and you should see the default Apache page. The web pages are in /var/www I normally add a symbolic link and change permissions on the html directory so I can add files easily:
1 2 3 4 |
$ cd ~ $ ln -s /var/www www $ cd www $ sudo chown -R <username>:www-data html/ |
Accessing a Network Drive
I want to be able to access some network drives from this server, these are setup as Windows (SMB) file shares.
1 2 |
$ sudo apt install cifs-utils $ sudo mkdir /mnt/nwData |
create a file with your file share username and password, this should go into /etc, I normally call the file the name of the server I want to connect to, and set permissions so it is only readable by root:
1 2 3 4 |
$ sudo nano /etc/<servername> USERNAME=<username> PASSWORD=<password> $ sudo chmod 500 /etc/<servername> |
And add the connection to the end of your /etc/fstab file, and mount the drives:
1 2 3 |
$ sudo nano /etc/fstab //192.168.1.101/BigFileStore /mnt/nwData cifs credentials=/etc/<servername>,iocharset=utf8,uid=<username> 0 0 $ sudo mount -a |
Check that it mounted with $ df -h. The file share will also automatically mount at boot.
Other Useful Things
Installing a downloaded .deb file with dependencies, in this case for the no longer manufactured Logitech Media Server:
1 2 3 4 5 |
$ cd ~/Downloads/ $ wget https://downloads.slimdevices.com/nightly/8.3/lms/3ee0cb0f42370ae36c97654ff151a0bb08f117a9/logitechmediaserver_8.3.0~1640066892_amd64.deb $ sudo apt install ./logitechmediaserver_8.3.0~1640066892_amd64.deb $ sudo systemctl enable logitechmediaserver.service $ sudo systemctl start logitechmediaserver.service |
Links and Sources
- More details on Installing LAMP
- Setup Samba Server on Debian 10
- Visual Studio Code: Remote Development using SSH
- Installing Node JS on Debian 11
- phpMyAdmin – a web frontend for MySql