LAMP is a common acronym for a server stack: Linux (operating system), Apache (web server), MySQL (database), and PHP (scripting language).

This combination is the most popular and powerful way to create a full environment for hosting websites.

Linux is a great choice for the operating system. Even an old computer or laptop, or my favorite hardware, a low-power single-board computer like the Raspberry Pi [https://www.raspberrypi.org/], can easily run a full server.

To get started, download a Linux Server distribution. My preferred choice is Ubuntu Server. For Raspberry Pi, there is a specific version that supports its ARM processor architecture.

If you are using Ubuntu Server 18.04 LTS, the easiest way to install all LAMP components is using tasksel (a Debian/Ubuntu tool that installs multiple related packages as a coordinated “task” onto your system):

sudo apt install tasksel -y
sudo tasksel install lamp-server

There are many tutorials that walk you through installing each LAMP component individually, but for a first setup, this tool handles everything at once. This video covers the whole process, from creating a virtual machine in VirtualBox to getting everything running smoothly [https://www.youtube.com/watch?v=m3tOY1isvBU]


PHPMyAdmin [https://www.phpmyadmin.net/] – A PHP-based web interface for managing your MySQL database. It makes it easy to browse and manage databases, tables, and data.

sudo apt install phpmyadmin

WordPress [https://wordpress.org/] – A website platform written in PHP that uses a MySQL database to store content. You don’t need to write any code to get a great, manageable site up and running.

sudo apt install wordpress

At this point, you have a full web server running a website and can start creating and publishing content privately or publicly. You may also want to consider the following tool: WebMin.


FileRun [https://www.filerun.com/] – A simple, secure, and reliable web application for storing and sharing files.

Follow the post: Installing ionCube and FileRun on Ubuntu 20.04 [Link].

Alternatively, for very low-resource devices (such as a Raspberry Pi Zero):

Tiny File Manager [https://tinyfilemanager.github.io/] – A single-file application for managing files.


NextCloud [https://nextcloud.com/] – This tool makes you the owner of your own cloud. You can create multiple users and share files limited only by your available storage. There is an official app for Android and iOS that includes remote mobile features comparable to many paid services, but completely free.

sudo apt install snap
sudo snap install nextcloud

If you have suggestions for cool applications or services to add to this post, let me know. I would be happy to test them and share my thoughts.

WebMin [http://www.webmin.com/] – A web-based interface for controlling your server. With it, you can update and upgrade your server, monitor CPU, RAM, and disk usage, install applications and services, and more.

sudo apt-get install webmin

Another common need is transferring files to or from your server. FTP and SSH can both help with that.

ProFTPd [http://www.proftpd.org/] – A popular FTP server that covers all standard file transfer needs. Note that FTP has no encryption, so it is best suited for transferring non-sensitive files.

apt-get install proftpd

OpenSSH-Server [https://www.openssh.com/] – Enables remote encrypted terminal connections, giving you full control of your server. It also supports secure file transfers using the scp command.

sudo apt-get install openssh-server

The syntax for transferring files over SSH:

scp <arg> [user@]SRC:file [user@]DEST:file

In the command above, <arg> represents optional arguments such as enabling compression or recursively copying directories. [user@] is optional and used when you need to specify a username for the remote host. SRC and DEST are the source and destination hosts, and file is the full or relative path to the file being transferred. SCP is a file transfer protocol that runs over SSH.


ANALYSING LOGS

GoAccess is an open-source real-time web log analyzer capable of parsing Apache, NGINX, CloudFront, and AWS ELB logs.

sudo apt install goaccess -y

Usage example:

goaccess -f /var/log/apache2/access.log
goaccess -f /var/log/apache2/access.log /var/log/apache2/access.log.1
  • Control Keys [Link]
    • Up Key and Down Key – Scroll the whole page.
    • F5 – Redraw the main page.
    • c – Set the color scheme.
    • q – Quit the program or return from a menu/module.
    • 0 to 10 – Select modules 1 to 10.
    • Shift+1 to Shift+5 – Select modules 11 to 15.
    • TAB or Shift+TAB – Iterate between modules.
    • o or ENTER – Expand a module.
      • j – Scroll down within the expanded module.
      • k – Scroll up within the expanded module.
      • g – Go to the first item within the expanded module.
      • G – Go to the last item within the expanded module.
      • Ctrl+f – Scroll forward one screen within an active module.
      • Ctrl+b – Scroll backward one screen within an active module.
    • s – Set the sort options.
    • / – Search across all modules (regex allowed).

For outputting the summary to a dynamic HTML file:

sudo goaccess -f /var/log/apache2/access.log -o /var/www/html/report.html
sudo goaccess -f /var/log/apache2/access.log -o /var/www/html/report.html --log-format=COMBINED --real-time-html
sudo goaccess -f /var/log/apache2/access.log -o report.html --log-format=COMBINED --real-time-html --addr=127.0.0.1 --port=9870 --ws-url=goaccess.local

Using awk to parse the log file:

awk -F\" '{print $6}' access.log | sort | uniq -c | sort -fr
  • Selecting the desired column to parse:
    • awk ‘{print $1}’ access.log
      • IP address (%h)
    • awk ‘{print $2}’ access.log
      • RFC 1413 identity (%l)
    • awk ‘{print $3}’ access.log
      • userid (%u)
    • awk ‘{print $4,5}’ access.log
      • date/time (%t)
    • awk ‘{print $9}’ access.log
      • status code (%>s)
    • awk ‘{print $10}’ access.log
      • size (%b)

BONUS

There are free web services that monitor your server and send notifications if it goes down or returns an error.

  • UpTimeRobot
    • The free plan monitors up to 50 servers at 5-minute intervals and sends email notifications when one goes down [Link].

Read more about functionalities over SSH

Using SCP and RSYNC for Copying and Syncing [Link].

Reverse Shell with AutoSSH [Link].

Setting Up and Copying SSH Keys [Link].