{"id":2721,"date":"2025-09-16T03:53:09","date_gmt":"2024-11-03T11:54:32","guid":{"rendered":""},"modified":"2025-02-02T00:46:19","modified_gmt":"2025-02-01T23:46:19","slug":"how-to-install-lamp-stack-linux-apache-mariadb-php-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-lamp-stack-linux-apache-mariadb-php-on-ubuntu-24-04\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 LAMP Stack (Linux, Apache, MariaDB, PHP) on Ubuntu 24.04"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<header>\n<h1>\u00a0<\/h1>\n<\/header>\n<article>\n<p>The <strong>LAMP stack<\/strong> (Linux, Apache, MariaDB, PHP) is one of the most popular web development stacks for hosting websites and web applications. It is an open-source solution that provides a flexible and powerful platform for creating dynamic web content. In this guide, we\u2019ll walk you through the steps to install the LAMP stack on <strong>Ubuntu 24.04<\/strong>. For optimal performance and scalability, it\u2019s recommended to host your LAMP stack on a . A <strong>VPS server<\/strong> provides the dedicated resources and flexibility required for high-performance web hosting.<\/p>\n<h2>Step 1: Update Your VPS Server<\/h2>\n<p>Before starting the installation, it\u2019s important to ensure your <a href=\"https:\/\/ie.netcloud24.com\">VPS server<\/a> is up to date. Run the following command to update your system:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n<p>By using a <strong>Windows VPS<\/strong>, you ensure that your LAMP stack runs efficiently with dedicated resources for better performance and stability.<\/p>\n<h2>Step 2: Install Apache<\/h2>\n<p>Apache is the most widely used web server in the world. It will handle HTTP requests and serve your website content. Install Apache using the following command:<\/p>\n<pre><code>sudo apt install apache2 -y<\/code><\/pre>\n<p>Once installed, start and enable Apache to run on boot:<\/p>\n<pre><code>sudo systemctl enable apache2 --now<\/code><\/pre>\n<p>To verify Apache is running, open your browser and visit <code>http:\/\/your-server-ip<\/code>. You should see the default Apache welcome page.<\/p>\n<h2>Step 3: Install MariaDB<\/h2>\n<p>MariaDB is a popular open-source database management system and a drop-in replacement for MySQL. Install MariaDB using the following command:<\/p>\n<pre><code>sudo apt install mariadb-server -y<\/code><\/pre>\n<p>After installation, secure your MariaDB instance with the following command:<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>This script will guide you through the process of securing your database server, including setting the root password and disabling remote root login. Follow the prompts to complete the setup.<\/p>\n<h2>Step 4: Install PHP<\/h2>\n<p>PHP is a server-side scripting language used to generate dynamic web pages. It works in conjunction with Apache and MariaDB to process and serve content. Install PHP and the necessary extensions for LAMP:<\/p>\n<pre><code>\r\nsudo apt install php php-mysql php-cli php-xml php-mbstring php-json php-zip -y\r\n<\/code><\/pre>\n<p>To verify that PHP is installed correctly, create a <code>phpinfo<\/code> page. First, navigate to the Apache web root directory:<\/p>\n<pre><code>cd \/var\/www\/html<\/code><\/pre>\n<p>Create a PHP test file:<\/p>\n<pre><code>sudo nano info.php<\/code><\/pre>\n<p>Add the following code to the file:<\/p>\n<pre><code>\r\n&lt;?php\r\nphpinfo();\r\n?&gt;\r\n<\/code><\/pre>\n<p>Save the file and exit. Now, open your browser and visit <code>http:\/\/your-server-ip\/info.php<\/code>. You should see the PHP information page, confirming that PHP is working correctly with Apache.<\/p>\n<h2>Step 5: Configure Apache to Use PHP<\/h2>\n<p>Next, configure Apache to handle PHP files. Open the Apache configuration file:<\/p>\n<pre><code>sudo nano \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/pre>\n<p>Find the following line:<\/p>\n<pre><code>\r\nDirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm\r\n<\/code><\/pre>\n<p>Move <code>index.php<\/code> to the beginning of the line so that Apache prioritizes PHP files:<\/p>\n<pre><code>\r\nDirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm\r\n<\/code><\/pre>\n<p>Save the file and exit. Restart Apache to apply the changes:<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h2>Step 6: Test Your LAMP Stack<\/h2>\n<p>Now that Apache, MariaDB, and PHP are installed and configured, you can test your LAMP stack by creating a sample PHP file:<\/p>\n<pre><code>sudo nano \/var\/www\/html\/test.php<\/code><\/pre>\n<p>Add the following code:<\/p>\n<pre><code>\r\n&lt;?php\r\necho \"LAMP Stack is working!\";\r\n?&gt;\r\n<\/code><\/pre>\n<p>Save and exit. Now, open your browser and visit <code>http:\/\/your-server-ip\/test.php<\/code>. You should see the message \u201cLAMP Stack is working!\u201d<\/p>\n<h2>Step 7: Optimize Your VPS Server for LAMP<\/h2>\n<p>To get the most out of your LAMP stack, hosting it on a  is the best option. A <strong>VPS server<\/strong> provides the dedicated CPU, RAM, and storage resources necessary to ensure high performance and stability, especially for websites and applications handling significant traffic. By using a VPS, you can also scale your infrastructure as needed, ensuring smooth operation even under heavy loads.<\/p>\n<h2>Conclusion<\/h2>\n<p>Installing the LAMP stack on Ubuntu 24.04 is a simple process that provides a powerful platform for web development and hosting. By hosting your LAMP stack on a , you can benefit from better performance, scalability, and control over your web hosting environment.<\/p>\n<p>For more information on VPS hosting and optimizing your LAMP setup, visit  today.<\/p>\n<\/article>\n<footer>\n<p>\u00a9 2024 Windows VPS &#8211; All Rights Reserved<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 The LAMP stack (Linux, Apache, MariaDB, PHP) is one of the most popular web development stacks for hosting websites and web applications. It is an open-source\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-2721","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=2721"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2721\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=2721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=2721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=2721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}