{"id":10589,"date":"2021-09-28T10:30:15","date_gmt":"2021-09-28T10:30:15","guid":{"rendered":"https:\/\/linuxways.net\/?p=10589"},"modified":"2021-09-28T10:30:15","modified_gmt":"2021-09-28T10:30:15","slug":"how-to-install-lamp-server-on-debian-11","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-install-lamp-server-on-debian-11\/","title":{"rendered":"How to Install LAMP Server on Debian 11"},"content":{"rendered":"<p>LAMP stack is one of the most popular and leading development stacks among developers. It stands for Linux Apache MySQL\/MariaDB and PHP. Apache is a free and open-source and extremely popular webserver. MySQL\/MariaDB is an opensource relational database management system and PHP is a server-side scripting language.<\/p>\n<p>In this guide, we walk you through the process of installing LAMP on Debian 11. Check how to <a href=\"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-lamp-stack-on-rocky-linux\/\">install LAMP on Rocky Linux 8 <\/a>and <a href=\"https:\/\/linuxways.net\/de\/centos\/how-to-install-lamp-stack-on-centos-8\/\">CentOS 8<\/a>.<\/p>\n<h2><strong>What you need<\/strong><\/h2>\n<p>Before getting started out, first establish you have the following prerequisites:<\/p>\n<ol>\n<li>An instance of Debian 11 server installed.<\/li>\n<li>A sudo user configured on the server<\/li>\n<\/ol>\n<p>Let us now install the popular LAMP stack on Debian Bulleye.<\/p>\n<h2><strong>Step 1: Update Debian 11 package lists<\/strong><\/h2>\n<p>It\u2019s essential to always start with updating the package index to start off on a clean slate. On your terminal, run the command:<\/p>\n<pre><strong>$ sudo apt update -y<\/strong><\/pre>\n<p>This should take just a few seconds, and once done, head over to the next step.<\/p>\n<h2><strong>Step 2: Install Apache webserver<\/strong><\/h2>\n<p>The next step is to install the popular Apache webserver. And to do this, execute:<\/p>\n<pre><strong>$ sudo apt install apache2 -y<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"169\" class=\"wp-image-10590\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-618.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-618.png 886w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-618-300x57.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-618-768x146.png 768w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/p>\n<p>This installs Apache alongside other additional packages, libraries, and dependencies. By default, Apache autostarts and you can confirm this by checking its status.<\/p>\n<pre><strong>$ sudo systemctl status apache2<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"223\" class=\"wp-image-10591\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-619.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-619.png 757w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-619-300x88.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<p>If, for whatever reason, Apache is not running, start the service by running the command:<\/p>\n<pre><strong>$ sudo systemctl start apache2<\/strong><\/pre>\n<p>Additionally, consider enabling Apache to start upon a reboot or every time the system is powered on as follows:<\/p>\n<pre><strong>$ sudo systemctl enable apache2<\/strong><\/pre>\n<p>On a web browser, visit your server\u2019s IP address or domain name to verify that, indeed, the webserver is accessible.<\/p>\n<pre><strong>http:\/\/server-ip<\/strong><\/pre>\n<p>You should get the Apache webserver welcome page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1308\" height=\"517\" class=\"wp-image-10592\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-620.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-620.png 1308w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-620-300x119.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-620-1024x405.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-620-768x304.png 768w\" sizes=\"auto, (max-width: 1308px) 100vw, 1308px\" \/><\/p>\n<p>That is a confirmation that Apache was successfully installed.<\/p>\n<h2><strong>Step 3: Install MariaDB database server<\/strong><\/h2>\n<p>MariaDB is an opensource relational database management system ( RDBMS) that is forked from MySQL. It\u2019s more robust, more secure and provides additional features such as Galera cluster, and cool storage engines such as InnoDB<\/p>\n<p>To install the MariaDB server, simply run the command:<\/p>\n<pre><strong>$ sudo apt install mariadb-server -y<\/strong><\/pre>\n<p>Like Apache, MariaDB starts automatically. You can verify the running status as shown.<\/p>\n<pre><strong>$ sudo systemctl status mariadb<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"110\" class=\"wp-image-10593\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-621.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-621.png 828w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-621-300x40.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-621-768x102.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/p>\n<p>If MariaDB is not running considering starting it.<\/p>\n<pre><strong>$ sudo systemctl start mariadb<\/strong><\/pre>\n<p>Then enable the service to start on boot time.<\/p>\n<pre><strong>$ sudo systemctl enable mariadb<\/strong><\/pre>\n<p>Equally important is the security of the database server. The default settings that MariaDB ships with are weak and can hackers can exploit them to breach the database.<\/p>\n<p>So, to harden MariaDB, run the command:<\/p>\n<pre><strong>$ sudo mysql_secure_installation<\/strong><\/pre>\n<p>This will pop up a few prompts which will guide you in hardening your server. Begin with setting a root password<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"748\" height=\"498\" class=\"wp-image-10594\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-622.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-622.png 748w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-622-300x200.png 300w\" sizes=\"auto, (max-width: 748px) 100vw, 748px\" \/><\/p>\n<p>Then type \u2018Y\u2019 for the remaining prompts to configure the database server to the most recommended security settings.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"574\" class=\"wp-image-10595\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-623.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-623.png 739w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-623-300x233.png 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/p>\n<p>To log in run the command<\/p>\n<pre><strong>$ sudo mysql -u root -p<\/strong><\/pre>\n<p>Type the root password and hit ENTER. To existing databases run the command:<\/p>\n<pre><strong>SHOW DATABASES;<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"349\" class=\"wp-image-10596\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-624.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-624.png 680w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-624-300x154.png 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>To confirm the version of MariaDB, run:<\/p>\n<pre><strong>SELECT VERSION();<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"574\" height=\"182\" class=\"wp-image-10597\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-625.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-625.png 574w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-625-300x95.png 300w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/strong><\/p>\n<p>To exit the database server, run the command:<\/p>\n<pre><strong>EXIT;<\/strong><\/pre>\n<h2><strong>Step 3: Install PHP scripting language<\/strong><\/h2>\n<p>Lastly, we will install PHP, which is a server-side scripting language used for supporting the development of dynamic web pages. By default, PHP 7.4 is hosted on Debian 11 repository. Therefore, we will install PHP and some additional PHP modules using the APT package manager as follows:<\/p>\n<pre><strong>$ sudo apt install php libapache2-mod-php php-zip php-mbstring php-cli php-common php-curl<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"894\" height=\"294\" class=\"wp-image-10598\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-626.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-626.png 894w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-626-300x99.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-626-768x253.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/p>\n<p>You can confirm if PHP is installed using the command:<\/p>\n<pre><strong>$ php -v<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"127\" class=\"wp-image-10599\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-627.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-627.png 609w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-627-300x63.png 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/strong><\/p>\n<p>In addition, you can verify this from a web browser by creating a sample PHP file in the document root folder<\/p>\n<pre><strong>$ sudo nano \/var\/www\/html\/info.php<\/strong><\/pre>\n<p>Paste the following lines<\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>phpinfo();<\/strong>\r\n\r\n<strong>?&gt;<\/strong><\/pre>\n<p>Save the file and browse the URL shown<\/p>\n<pre><a href=\"http:\/\/server-ip\/info.php\"><strong>http:\/\/server-ip\/info.php<\/strong><\/a><\/pre>\n<p>You should get the PHP page displayed as demonstrated.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1298\" height=\"598\" class=\"wp-image-10600\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-628.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-628.png 1298w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-628-300x138.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-628-1024x472.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-628-768x354.png 768w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/strong><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Congratulations on coming this far. In this walkthrough, we demonstrated a step-by-step procedure of how you can install LAMP stack on the Debian 11 Bullseye server. From here, you can start developing and testing your web applications using the LAMP stack.<\/p>","protected":false},"excerpt":{"rendered":"<p>LAMP stack is one of the most popular and leading development stacks among developers. It stands for Linux Apache MySQL\/MariaDB and PHP. Apache is a free and open-source&hellip;<\/p>","protected":false},"author":1,"featured_media":10675,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[521,577],"class_list":["post-10589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-11","tag-lamp-server"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10589","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=10589"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10589\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/10675"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=10589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=10589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=10589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}