{"id":10141,"date":"2021-09-02T20:31:07","date_gmt":"2021-09-02T17:31:07","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10141"},"modified":"2024-03-18T14:13:02","modified_gmt":"2024-03-18T11:13:02","slug":"install-lamp-stack-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-lamp-stack-on-debian-11\/","title":{"rendered":"Install LAMP Stack on Debian 11"},"content":{"rendered":"\n<p>Follow through this guide to learn how to install LAMP Stack on Debian 11. If you are looking at building some web application, LAMP stack is the first thing you might need. As you already know, LAMP is a group of opensource web development software; Linux OS,&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/httpd.apache.org\/\" target=\"_blank\">Apache http server<\/a>,&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/mariadb.org\/\" target=\"_blank\">MariaDB<\/a>\/<a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL<\/a>&nbsp;relational database management systems and&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.php.net\/\" target=\"_blank\">PHP<\/a>&nbsp;web scripting language.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing LAMP Stack on Debian 11<\/h2>\n\n\n\n<p>As per the acronym, Linux system is the first component of LAMP stack. And of course Debian 11 is our first component of LAMP stack.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>To begin with, update and upgrade your system packages;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt upgrade<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Apache Web Server on Debian 11<\/h3>\n\n\n\n<p>Apache web server can be installed by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install apache2 -y<\/code><\/pre>\n\n\n\n<p>Once the installation is done, Apache is started and enabled to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status apache2<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf apache2.service - The Apache HTTP Server\n     Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n     Active: active (running) since Thu 2021-09-02 19:57:45 EAT; 1s ago\n       Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n    Process: 2223 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=0\/SUCCESS)\n   Main PID: 2227 (apache2)\n      Tasks: 55 (limit: 1133)\n     Memory: 8.7M\n        CPU: 25ms\n     CGroup: \/system.slice\/apache2.service\n             \u251c\u25002227 \/usr\/sbin\/apache2 -k start\n             \u251c\u25002228 \/usr\/sbin\/apache2 -k start\n             \u2514\u25002229 \/usr\/sbin\/apache2 -k start\n\nSep 02 19:57:45 bullseye.kifarunix-demo.com systemd[1]: Starting The Apache HTTP Server...\nSep 02 19:57:45 bullseye.kifarunix-demo.com systemd[1]: Started The Apache HTTP Server.\n<\/code><\/pre>\n\n\n\n<p>Verify external access to Apache by navigating to your browser and entering the server IP address or resolvable hostname as&nbsp;<strong><code>http:\/\/Server.IP_or_hostname<\/code><\/strong>. You should land on Apache HTTP server test page.<\/p>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/apache2-2.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1023\" height=\"954\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/apache2-2.png\" alt=\"Install LAMP Stack on Debian 11\" class=\"wp-image-10294\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/apache2-2.png?v=1630603485 1023w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/apache2-2-768x716.png?v=1630603485 768w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><\/figure><\/a><\/div>\n\n\n\n<p>To restrict access to Apache, you can install UFW;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install ufw<\/code><\/pre>\n\n\n\n<p>Once UFW is installed, you can enable it to secure your system against unrestricted access.<\/p>\n\n\n\n<p>Before you can enable UFW, ensure that you have opened SSH port, in case you had logged in via SSH.<\/p>\n\n\n\n<p>Replace <strong><strong>SOURCE_IP<\/strong>, <\/strong> with the address from which you are logging in from.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ufw allow from <strong>SOURCE_IP<\/strong> to any port 22 proto tcp<\/code><\/pre>\n\n\n\n<p>You can then allow external access to Apache;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ufw allow \"WWW Full\"<\/code><\/pre>\n\n\n\n<p>or simply run&nbsp;<strong><code>ufw allow 80\/tcp<\/code><\/strong>&nbsp;to allow HTTP traffic.<\/p>\n\n\n\n<p>Great. Proceed to install MySQL\/MariaDB on Debian 11.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install MySQL Database Server on Debian 11<\/h3>\n\n\n\n<p>In this demo, we are running LAMP stack on Debian 11 with MySQL 8.<\/p>\n\n\n\n<p>Therefore, follow the link below to install MySQL 8 on Debian 11;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mysql-8-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MySQL 8 on Debian 11<\/a><\/p>\n\n\n\n<p>If you want to use MariaDB 10.6, then check the guide below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mariadb-10-6-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install MariaDB 10.6 on Debian 11<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install PHP on Debian 11<\/h3>\n\n\n\n<p>PHP is the last but not least component in LAMP Stack.<\/p>\n\n\n\n<p>Follow the link below to learn how to install PHP on Debian 11;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-php-7-1-7-2-7-3-7-4-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install PHP 7.1\/7.2\/7.3\/7.4 on Debian 11<\/a><\/p>\n\n\n\n<p>If you want to use PHP 8, then check the guide below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-php-8-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install PHP 8 on Debian 11<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing PHP Modules on Debian 11<\/h4>\n\n\n\n<p>In this demo, we are going to use PHP 7.4 for our LAMP stack.<\/p>\n\n\n\n<p>Installation of PHP installs with itself other PHP modules such as,&nbsp;<code>libapache2-mod-php7.4 libsodium23 php php-common php7.4 php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline psmisc<\/code>.<\/p>\n\n\n\n<p>Install MySQL module for PHP and any other module you may need for your web application.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install php-mysql<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Testing PHP Processing&nbsp;on Debian 11<\/h4>\n\n\n\n<p>You can test PHP to confirm that is working as required as well check the version and installed modules using the simple PHP info script.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo \"&lt;?php phpinfo(); ?&gt;\" &gt; \/var\/www\/html\/info.php<\/code><\/pre>\n\n\n\n<p>Restart Apache<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart apache2<\/code><\/pre>\n\n\n\n<p>Next, navigate to the browser and enter the address,&nbsp;<strong>http:\/\/&lt;server-IP&gt;\/info.php<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1251\" height=\"933\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/php.png\" alt=\"\" class=\"wp-image-10293\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/php.png?v=1630603459 1251w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/php-768x573.png?v=1630603459 768w\" sizes=\"(max-width: 1251px) 100vw, 1251px\" \/><\/figure>\n\n\n\n<p>If you see this page, then PHP installation is working pretty well and Apache can server PHP content!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-centos-8\/\" target=\"_blank\">Install LAMP Stack on CentOS 8<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-lamp-stack-with-mariadb-10-on-debian-10-buster\/\" target=\"_blank\">Install LAMP Stack with MariaDB 10 on Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-fedora-30\/\" target=\"_blank\">Install LAMP Stack on Fedora 30<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-debian-9\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install LAMP Stack on Debian 9<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to install LAMP Stack on Debian 11. If you are looking at building some web application, LAMP stack<\/p>\n","protected":false},"author":3,"featured_media":10296,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,254,299,201,253],"tags":[3958,4050,4048,4049,204,4047],"class_list":["post-10141","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-apache","category-database","category-lamp-stack","category-web-servers","tag-debian-11","tag-debian-11-install-lamp-stack","tag-debian-11-lamp-stack","tag-install-lamp-stack-on-debian-11","tag-lamp-stack","tag-lamp-stack-debian-11","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10141"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=10141"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10141\/revisions"}],"predecessor-version":[{"id":21667,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10141\/revisions\/21667"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10296"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}