{"id":21246,"date":"2023-09-27T10:03:23","date_gmt":"2023-09-27T10:03:23","guid":{"rendered":"https:\/\/linuxways.net\/?p=21246"},"modified":"2023-09-27T10:03:23","modified_gmt":"2023-09-27T10:03:23","slug":"how-to-install-and-configure-lamp-stack","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-and-configure-lamp-stack\/","title":{"rendered":"How to Install and Configure LAMP Stack?"},"content":{"rendered":"<p>For Web Application Development we mostly use or prefer either the MERN stack or the MEAN stack. LAMP Stack is also used for <strong>Web Application Development. <\/strong>It consists of <strong>Four Components<\/strong> that the term \u201cLAMP\u201d is derived from:<\/p>\n<ol>\n<li><strong>L<\/strong>inux Operating System, which works as a server operating system.<\/li>\n<li><strong>A<\/strong>pache HTTP Web Server.<\/li>\n<li><strong>M<\/strong>ySQL, which is used for Database Management.<\/li>\n<li><strong>P<\/strong>HP programming language.<\/li>\n<\/ol>\n<p>This article showcases the installation and configuration of LAMP Stack in Linux Distribution, mainly Ubuntu.<\/p>\n<h2><strong>How to Install and Configure LAMP Stack on Ubuntu 22.04?<\/strong><\/h2>\n<p>The steps below will guide you through the complete process of installing and configuring the LAMP Stack in Ubuntu, which is among the popular Linux Distribution Systems.<\/p>\n<h3><strong>Step 1: Installing Apache Server<\/strong><\/h3>\n<p>Before installing the Apache HTTP Server, ensure the package list is up to date by using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p>\u201csudo\u201d gives the user admin privileges.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"943\" height=\"601\" class=\"wp-image-21247\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-1.png 943w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-1-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-1-768x489.png 768w\" sizes=\"auto, (max-width: 943px) 100vw, 943px\" \/><\/p>\n<p>Run the command below to install Apache Packages:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> apache2<\/div><\/div>\n<p>During installation, it will ask for confirmation, press \u201cY\u201d to continue the process:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"581\" class=\"wp-image-21248\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-2.png 960w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-2-300x182.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-2-768x465.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>To check the status of the installed Apache Server, run the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> service apache2 status<\/div><\/div>\n<p>If it is installed, it will highlight the server as \u201crunning\u201d in the command prompt:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"327\" class=\"wp-image-21249\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-3.png 973w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-3-300x101.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-3-768x258.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/p>\n<p>Now, check if your UFW Firewall contains the Apache profile. The UFW(Uncomplicated Firewall) provides a simple way to configure your firewall. Run the command below to check your Apache profile in UFW:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw app list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"966\" height=\"157\" class=\"wp-image-21250\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-4.png 966w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-4-300x49.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-4-768x125.png 768w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/p>\n<p>Here we have the Apache Full Profile. Ensure that the <strong>Apache Full<\/strong> allows traffic on ports 80 and 443. <strong>Port 80 <\/strong>allows the information to be in plain text between the browser and server, whereas <strong>Port 443 <\/strong>allows the information to remain encrypted between the browser and server. Check Ports by running the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw app info <span class=\"st0\">&quot;Apache Full&quot;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"966\" height=\"163\" class=\"wp-image-21251\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-5.png 966w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-5-300x51.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-5-768x130.png 768w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/p>\n<p>Now to check whether your Apache Server is running, run any internet browser in Ubuntu, and in the address bar type \u201c<strong>localhost<\/strong>\u201d. It will navigate you to the Apache Web Page:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1211\" height=\"776\" class=\"wp-image-21252\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-6.png 1211w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-6-300x192.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-6-1024x656.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-6-768x492.png 768w\" sizes=\"auto, (max-width: 1211px) 100vw, 1211px\" \/><\/p>\n<p>If the default Apache Web Page displays, it means that the server is up and running.<\/p>\n<h3><strong>Step 2: Installing MySQL<\/strong><\/h3>\n<p>For the Database Management System in LAMP Stack, MySQL is used. To install MySQL in Ubuntu, execute the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> mysql-server<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"489\" class=\"wp-image-21253\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-7.png 969w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-7-300x151.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-7-768x388.png 768w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/p>\n<p>When installed you can see the terminal ensuring the \u201csql-server\u201d is running<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"347\" class=\"wp-image-21254\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-8.png 825w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-8-300x126.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-8-768x323.png 768w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>You can also verify the SQL Server installation using the command<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">mysql <span class=\"re5\">-V<\/span><\/div><\/div>\n<p>This will show the \u201csql-server\u201d version<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"76\" class=\"wp-image-21255\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-9.png 805w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-9-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-9-768x73.png 768w\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" \/><\/p>\n<h3><strong>Step 3: Installing PHP<\/strong><\/h3>\n<p>As PHP integrates well with MySQL, it is preferred over Python and Pearl for Web Development Projects. Although Python and Pearl can also be used, but the speed and complexity of Web Application usually improves when PHP is embedded into HTML.<\/p>\n<p>To install PHP, obtain the packages first by using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> php libapache2-mod-php php-mysql<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"523\" class=\"wp-image-21256\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-10.png 960w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-10-300x163.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-10-768x418.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>During installation, it will ask for confirmation, press \u201cY\u201d to continue the process. Once the necessary packages are obtained, modify the Apache Server Files using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>apache2<span class=\"sy0\">\/<\/span>mods-enabled<span class=\"sy0\">\/<\/span>dir.conf<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"970\" height=\"224\" class=\"wp-image-21257\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-11.png 970w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-11-300x69.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-11-768x177.png 768w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/p>\n<p>By default, the Apache server looks for the \u201cindex.html\u201d file. Change the \u201c<strong>index.html<\/strong>\u201d file with \u201c<strong>index.php<\/strong>\u201d by editing the file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"967\" height=\"189\" class=\"wp-image-21258\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-12.png 967w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-12-300x59.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-12-768x150.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>Save the file and then exit using \u201c<strong>Ctrl+X<\/strong>\u201d.<\/p>\n<h3><strong>Step 4: Rebooting Apache<\/strong><\/h3>\n<p>Using the following command, reboot the Apache server for the changes to take effect:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl restart apache2<\/div><\/div>\n<p>If the server restarts, the command line will move to the next line:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"39\" class=\"wp-image-21259\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-13.png 973w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-13-300x12.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-13-768x31.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/p>\n<h3><strong>Step 5: Testing <\/strong><\/h3>\n<p>Create a file in the root directory with a basic PHP Script to check if the LAMP installation is working or not on your local host. Using the command below, create a file in the root directory:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>var<span class=\"sy0\">\/<\/span>www<span class=\"sy0\">\/<\/span>html<span class=\"sy0\">\/<\/span>info.php<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"967\" height=\"26\" class=\"wp-image-21260\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-14.png 967w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-14-300x8.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-14-768x21.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>Once executed, the file will open:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"969\" height=\"288\" class=\"wp-image-21261\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-15.png 969w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-15-300x89.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-15-768x228.png 768w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/p>\n<p>Add the PHP script below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"sy0\">&lt;<\/span>?php<br \/>\nphpinfo <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span>;<br \/>\n?<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>Save the file and then exit by pressing the \u201cCtrl+X\u201d keys:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"99\" class=\"wp-image-21262\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-16.png 968w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-16-300x31.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-16-768x79.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>Fire up your internet browser on Ubuntu and in the address bar, type the following address:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">localhost<span class=\"sy0\">\/<\/span>info.php<\/div><\/div>\n<p>This address will open the PHP Details:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1210\" height=\"771\" class=\"wp-image-21263\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-17.png 1210w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-17-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-17-1024x652.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21246-17-768x489.png 768w\" sizes=\"auto, (max-width: 1210px) 100vw, 1210px\" \/><\/p>\n<p>That\u2019s all about installing and configuring the LAMP Stack on Ubuntu 22.04.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Install and Configure LAMP Stack in Ubuntu by installing Apache Server, setting up MySQL, integrating PHP, and then testing LAMP on localhost. LAMP is a common open-source software stack that developers use to build interactive web pages and web applications. Depending on the scope of our web application, LAMP is typically fast and reliable compared to other stacks like MERN and MEAN. In this article, we explored what the LAMP stack is, dealt with the installation process, and analyzed the configuration of the LAMP Stack in Ubuntu.<\/p>","protected":false},"excerpt":{"rendered":"<p>Install and Configure LAMP Stack in Ubuntu by installing Apache Server, setting up MySQL, integrating PHP, and then testing LAMP on localhost. <\/p>","protected":false},"author":110,"featured_media":21264,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-21246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21246"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21246\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/21264"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}