Install LAMP Server on Ubuntu 24.04

This guide will walk you through setting up a powerful development environment on your Ubuntu 24.04 machine, equipping you with everything you need to build and deploy amazing applications.

First, let’s ensure our system is up-to-date and install the core packages that will form the backbone of our development environment:

sudo apt-get update
sudo apt-get install apache2 mysql-server php8.3 libapache2-mod-php libapache2-mod-php8.3 php8.3-mysql php8.3-curl php8.3-cgi php8.3-gd sshguard git htop curl smartmontools openssh-server htpdate mailutils php8.3-mbstring

Here’s a breakdown of what we’re installing:

  • apache2: The popular Apache web server, essential for serving web applications.
  • mysql-server: A robust database server for storing application data.
  • php8.3: The latest version of PHP for server-side scripting.
  • libapache2-mod-php libapache2-mod-php8.3: Modules to integrate PHP with Apache.
  • php8.3-mysql php8.3-curl php8.3-cgi php8.3-gd php8.3-mbstring: Essential PHP extensions for database connectivity, web requests, image processing, and more.
  • sshguard: A security tool to protect against brute-force SSH attacks.
  • git: The ubiquitous version control system.
  • htop: An interactive system monitor for tracking resource usage.
  • curl: A command-line tool for transferring data from or to a server.
  • smartmontools: Utilities for monitoring the health of your hard drives.
  • openssh-server: Enables secure remote access to your machine.
  • htpdate: A tool for synchronizing your system time with a time server.
  • mailutils: Tools for sending and receiving email from the command line.

Enabling User Directories in Apache

To allow users to host web content from their home directories, we’ll enable Apache’s userdir module:

sudo a2enmod userdir

Enabling PHP in userdir

Edit the file php8.3.conf and comment out last lines as mentioned in the comment

sudo nano /etc/apache2/mods-available/php8.3.conf

Securing MySQL

It’s crucial to set a strong password for the MySQL root user. We’ll do this by accessing the MySQL shell:

sudo mysql

Then, execute the following SQL commands:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password'; 
flush privileges;
exit;

Remember to replace 'your_password' with a secure password!

Exploring Further

This setup provides a solid foundation for your development journey on Ubuntu 24.04. You can further customize your environment by installing IDEs, text editors, and other tools tailored to your specific needs.

Leave a Reply

Your email address will not be published. Required fields are marked *