How to Install LAMP Stack on Ubuntu 24.04
The LAMP Stack (Linux, Apache, MySQL/MariaDB, PHP) is a powerful platform for hosting dynamic websites and web applications. Below are the steps to install and configure the LAMP stack on Ubuntu 24.04.
Step 1: Update System Packages
Start by updating the package lists to ensure your system has the latest updates. Open a terminal and run:
Step 2: Install Apache Web Server
Apache is the web server for serving your website content. Install it using:
Once installed, enable and start the Apache service:
To check if Apache is running, open your web browser and navigate to http://your-server-ip
. You should see the default Apache page.
Step 3: Install MySQL or MariaDB
For managing databases, you can choose between MySQL or MariaDB. Install MySQL by running:
Secure the installation with:
Follow the prompts to set up the root password and enhance security.
To log in to the MySQL shell, run:
For MariaDB, use this command instead:
Step 4: Install PHP
PHP is the server-side scripting language. Install PHP and the necessary modules with:
To test PHP, create a test file in /var/www/html
:
Add the following content:
Save the file and access it in a browser: http://your-server-ip/info.php
. If you see the PHP info page, PHP is working correctly.
Step 5: Adjust Firewall Settings
Ensure your firewall allows HTTP and HTTPS traffic:
Check the status of the firewall with:
Step 6: Test the LAMP Stack
- Apache: Visit
http://your-server-ip
. - MySQL: Use the command line or a tool like phpMyAdmin to verify database access.
- PHP: Visit
http://your-server-ip/info.php
.
Step 7: Optional: Install phpMyAdmin
If you prefer a graphical interface for managing databases, install phpMyAdmin:
During installation, select Apache and configure the database with the prompts. Access phpMyAdmin at http://your-server-ip/phpmyadmin
.
Conclusion
You now have a fully functional LAMP stack on Ubuntu 24.04. This setup is perfect for hosting websites, running CMS platforms like WordPress, or deploying custom web applications.
For further configuration, consider securing your Apache and MySQL services and optimizing PHP for performance.
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন