LAMP is a very common acronym for a Server (Linux) that runs a Web Server (Apache) with Database (MySQL) and Script Language (PHP).

This package is the most common and also very powerful combination of functionalities that creates one full environment for websites.

Linux, of course, the best operating system you can choose. Even one old computer or laptop, or my favorite hardware, a low energy consumption single-board computer called Raspberry Pi [https://www.raspberrypi.org/] can easily run a full server.

To make it, you just download one Linux Server distribution, my preferred is Ubuntu Server. For Raspberry Pi, there is one particular version that fits the ARM process architecture of the computer.

If you are using Ubuntu Server 18.04 LTS the easiest way to install all the components for a LAMP server is using tasksel (Tasksel¬†is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system.):

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

There are many tutorials that guide you to install all the components of LAMP individually step-by-step, but for the first time, this tool will do it all for you at once. This cool video shows everything you may face during this task since creating one virtual machine on Virtual Box to make it runs nice and clean [https://www.youtube.com/watch?v=m3tOY1isvBU]


PHPMyAdmin [https://www.phpmyadmin.net/] – This is a tool that is written in PHP and connects to your MySQL database as a visual web client and makes it very easy to access and manage the database, tables and also add, change and remove data in it.

sudo apt install phpmyadmin

WordPress [https://wordpress.org/] – This is a website platform that is written in PHP and requires one MySQL database to store the website information. You don’t need to write all the codes to get one great manageable site, WordPress will do it for you.

sudo apt install wordpress

At this point, you have one full web server running one cool website and you can start to create content and post privately or publicly on the internet. But there is one additional tool that you may want to use called 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].

Or alternatively, for very low resources (such as RaspberryPi Zero):

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


NextCloud [https://nextcloud.com/] – This spectacular tool makes you the owner of your cloud. You can create many users and share files in volumes that only depend on the capacity of the hard drives you have. There is one official app available for Android or iOS that incorporates remote mobile functionalities like many paid services, but free!

sudo apt install snap
sudo snap install nextcloud

If you have any suggestions of cool applications or services that can be added to this post let me know. I will be happy to test it and give my hint for it.

WebMin [http://www.webmin.com/] – This is one web interface tool that gives you the control of your server. With this tool, you can since update/upgrade your server, see the CPU/RAM/Disks usage, install application and services, etc.

sudo apt-get install webmin

Another common necessity is to transfer files to or from your server and FTP and/or SSH can help you with that.

ProFTPd [http://www.proftpd.org/] – This is one popular FTP server that certainly will provide all the functionalities you need. Note that FTP has no cryptography, so it is a great simple way to transfer files that are not sensitive.

apt-get install proftpd

OpenSSH-Server [https://www.openssh.com/] – This tool gives you the ability to remotely start one encrypted terminal connection that will allow you to have absolute control of the server. It also allows you to start a secure file transfer with the command scp.

sudo apt-get install openssh-server

The syntax for transferring files over SSH:

scp <arg> [[email protected]]SRC:file [[email protected]]DEST:file

Quickly explaining the command above <arg> are the arguments you can specify live, compression while transferring of recursively copy directories, [[email protected]] is optional in case you need to inform the user you want to log in in that host, SRC and DEST are origin and destiny hosts and file can be the full or relative path to the file you want to send and where you want it to be placed. The SCP is a file transfer protocol that runs over the SSH.


ANALYSING LOGS

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

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 – To select modules from 1 to 10.
    • Shift+1 to Shift+5 – TO select modules from 11 to 15.
    • TAB or Shift+TAB– Iterate between modules.
    • o or ENTER – To 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 – Got 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 resources 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 sed to part 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 can keep track and monitor your server still alive and send you notifications if it goes down or if the response is not successful for any internal error.

  • UpTimeRobot
    • The free service is capable of monitoring up to 50 servers with the 5 minutes interval and sending email notifications when it 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].

One Reply to “LAMP (Linux, Apache, MySQL, PHP) and Web Services”

Comments are closed.