{"id":10143,"date":"2021-09-19T10:16:05","date_gmt":"2021-09-19T07:16:05","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10143"},"modified":"2024-03-18T13:59:39","modified_gmt":"2024-03-18T10:59:39","slug":"quick-way-to-install-lemp-stack-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/quick-way-to-install-lemp-stack-on-debian-11\/","title":{"rendered":"Quick Way to Install LEMP Stack on Debian 11"},"content":{"rendered":"\n<p>This guide presents a quick way to install&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/lemp.io\/\" target=\"_blank\">LEMP<\/a>&nbsp;Stack on Debian 11.<\/p>\n\n\n\n<p>LEMP stack is an acronym for the commonly used web application and deployment component;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux system<\/li>\n\n\n\n<li><a href=\"https:\/\/nginx.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">ENginx<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.mysql.com\/\" target=\"_blank\">MySQL<\/a>\/<a rel=\"noreferrer noopener\" href=\"https:\/\/mariadb.org\/\" target=\"_blank\">MariaDB<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/php.net\/\" target=\"_blank\">PHP<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing LEMP Stack on Debian 11<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Install Linux System<\/h3>\n\n\n\n<p>The first component of the LEMP stack is Linux Operating System, which is in this case is the Debian 11.<\/p>\n\n\n\n<p>If you have not installed it already, see the link below on how to install Debian 11 on VirtualBox.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-debian-11-on-virtualbox\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Debian 11 on VirtualBox<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Nginx on Debian 11<\/h3>\n\n\n\n<p>To install Nginx on Debian 11, just run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install nginx<\/code><\/pre>\n\n\n\n<p>When Nginx is installed, it is started and enabled to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status nginx<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf nginx.service - A high performance web server and a reverse proxy server\n     Loaded: loaded (\/lib\/systemd\/system\/nginx.service; enabled; vendor preset: enabled)\n     Active: active (running) since Sun 2021-09-19 08:34:46 EAT; 2min 24s ago\n       Docs: man:nginx(8)\n    Process: 1313 ExecStartPre=\/usr\/sbin\/nginx -t -q -g daemon on; master_process on; (code=exited, status=0\/SUCCESS)\n    Process: 1314 ExecStart=\/usr\/sbin\/nginx -g daemon on; master_process on; (code=exited, status=0\/SUCCESS)\n   Main PID: 1396 (nginx)\n      Tasks: 3 (limit: 3547)\n     Memory: 6.2M\n        CPU: 70ms\n     CGroup: \/system.slice\/nginx.service\n             \u251c\u25001396 nginx: master process \/usr\/sbin\/nginx -g daemon on; master_process on;\n             \u251c\u25001398 nginx: worker process\n             \u2514\u25001399 nginx: worker process\n\nSep 19 08:34:46 debian11 systemd[1]: Starting A high performance web server and a reverse proxy server...\nSep 19 08:34:46 debian11 systemd[1]: Started A high performance web server and a reverse proxy server.\n<\/code><\/pre>\n\n\n\n<p>To check if it is enabled to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl is-enabled nginx<\/code><\/pre>\n\n\n\n<p>If it is enabled, then the output of the command above should be <strong>enabled<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install MySQL\/MariaDB on Debian 11<\/h3>\n\n\n\n<p>In this guide, we are going to use MariaDB 10.6. To install MariaDB 10.6 on Debian 11, follow the link 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<p>You can as well use MySQL 8<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-mysql-8-on-debian-11\/\">Install MySQL 8 on Debian 11<\/a><\/p>\n\n\n\n<p>Just to confirm the version of installed of MariaDB installed;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql  Ver 15.1 Distrib 10.6.4-MariaDB, for debian-linux-gnu (x86_64) using readline EditLine wrapper<\/code><\/pre>\n\n\n\n<p>When installed, MariaDB is started and enabled to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status mariadb<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf mariadb.service - MariaDB 10.6.4 database server\n     Loaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: enabled)\n    Drop-In: \/etc\/systemd\/system\/mariadb.service.d\n             \u2514\u2500migrated-from-my.cnf-settings.conf\n     Active: active (running) since Sun 2021-09-19 09:22:30 EAT; 32s ago\n       Docs: man:mariadbd(8)\n             https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\n    Process: 3619 ExecStartPre=\/usr\/bin\/install -m 755 -o mysql -g root -d \/var\/run\/mysqld (code=exited, status=0\/SUCCESS)\n    Process: 3620 ExecStartPre=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0\/SUCCESS)\n    Process: 3622 ExecStartPre=\/bin\/sh -c [ ! -e \/usr\/bin\/galera_recovery ] && VAR= ||   VAR=`cd \/usr\/bin\/..; \/usr\/bin\/galera_recovery`; [ $? -eq 0 ]   && systemctl set-en>\n    Process: 3682 ExecStartPost=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0\/SUCCESS)\n    Process: 3684 ExecStartPost=\/etc\/mysql\/debian-start (code=exited, status=0\/SUCCESS)\n   Main PID: 3669 (mariadbd)\n     Status: \"Taking your SQL requests now...\"\n      Tasks: 18 (limit: 1133)\n     Memory: 78.5M\n        CPU: 377ms\n     CGroup: \/system.slice\/mariadb.service\n             \u251c\u25003669 \/usr\/sbin\/mariadbd\n             \u251c\u25003685 \/bin\/bash \/etc\/mysql\/debian-start\n             \u251c\u25003687 \/usr\/bin\/mysql_upgrade --defaults-extra-file=\/etc\/mysql\/debian.cnf --version-check\n             \u251c\u25003688 grep -E -v ^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))\n             \u251c\u25003689 logger -p daemon warn -i -t\/etc\/mysql\/debian-start\n             \u251c\u25003709 sh -c '\/usr\/bin\/mysql' --defaults-file=\/tmp\/mysql_upgrade-2f6zbZ --database=mysql --batch --force --silent < \/tmp\/sqlBWpgvY 2>&1\n             \u2514\u25003710 \/usr\/bin\/mysql --defaults-file=\/tmp\/mysql_upgrade-2f6zbZ --database=mysql --batch --force --silent\n\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.schema_unused_indexes                          OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.session                                        OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.session_ssl_status                             OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statement_analysis                             OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statements_with_errors_or_warnings             OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statements_with_full_table_scans               OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statements_with_runtimes_in_95th_percentile    OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statements_with_sorting                        OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.statements_with_temp_tables                    OK\nSep 19 09:22:31 debian11 \/etc\/mysql\/debian-start[3689]: sys.user_summary                                   OK\n<\/code><\/pre>\n\n\n\n<p>Check if it enabled to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl is-enabled mariadb<\/code><\/pre>\n\n\n\n<pre id=\"block-5098d5a2-fb7d-4f41-b40c-3657da2b9654\" class=\"wp-block-preformatted\">enabled<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install PHP on Debian 11<\/h3>\n\n\n\n<p>Follow the links below to install your preferred PHP  version.<\/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><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<p>In this setup, we will use PHP 7.4.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>php -v<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>PHP 7.4.21 (cli) (built: Jul  2 2021 03:59:48) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies<\/code><\/pre>\n\n\n\n<p>Install Other Required PHP extensions<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install php-fpm php-mysql<\/code><\/pre>\n\n\n\n<p>For any other additional PHP extension that you might need, simply get the extension name and run the command below to install it, replacing <strong>EXTENSION<\/strong> with the extension in question.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install php-EXTENSION<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Nginx for PHP Processing<\/h3>\n\n\n\n<p>For Nginx to process PHP pages, you need to include&nbsp;<strong>index.php<\/strong>&nbsp;as a value for the&nbsp;<strong>index<\/strong>&nbsp;parameter. Since we are using the default configuration for testing, edit the it as follows;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's|\\tindex index.html|\\tindex index.php index.html|' \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n\n\n\n<p>The command above will add <strong>index.php<\/strong> to the snippet below on <strong><code>\/etc\/nginx\/sites-enabled\/default<\/code><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n        root \/var\/www\/html;\n\n        # Add index.php to the list if you are using PHP\n        index <strong>index.php<\/strong> index.html index.htm index.nginx-debian.html;\n...<\/code><\/pre>\n\n\n\n<p>Also, you need to configure Nginx to pass PHP scripts to FastCGI server.<\/p>\n\n\n\n<p>Update the following lines;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n        # pass PHP scripts to FastCGI server\n        #\n        #location ~ \\.php$ {\n        #       include snippets\/fastcgi-php.conf;\n        #\n        #       # With php-fpm (or other unix sockets):\n        #       fastcgi_pass unix:\/run\/php\/php7.4-fpm.sock;\n        #       # With php-cgi (or other tcp sockets):\n        #       fastcgi_pass 127.0.0.1:9000;\n        #}\n<\/code><\/pre>\n\n\n\n<p>Such that they look like;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        # pass PHP scripts to FastCGI server\n<strong>        location ~ \\.php$ {\n               include snippets\/fastcgi-php.conf;\n               fastcgi_pass unix:\/run\/php\/php7.4-fpm.sock;\n        }<\/strong><\/code><\/pre>\n\n\n\n<p>Save and exit the configuration file.<\/p>\n\n\n\n<p>Test Nginx configuration<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -t<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/code><\/pre>\n\n\n\n<p>Restart Nginx and FastCGI process manager.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart nginx php7.4-fpm<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Test PHP Processing<\/h3>\n\n\n\n<p>To test PHP processing, create a PHP test page under the Apache web root directory, usually,&nbsp;<strong>\/var\/www\/html<\/strong>, with the following content.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo '&lt;?php phpinfo();' &gt; \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n<p>To test PHP processing, navigate to the browser and enter the address;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>http:\/\/&lt;server-IP&gt;\/test.php<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"959\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/lemp-stack-1.png\" alt=\"\" class=\"wp-image-10459\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/lemp-stack-1.png?v=1632035712 1080w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/lemp-stack-1-768x682.png?v=1632035712 768w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p>Remove the PHP test page once done.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-openldap-server-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Setup OpenLDAP Server on Debian 11<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-clamav-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install ClamAV on Debian 11<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide presents a quick way to install&nbsp;LEMP&nbsp;Stack on Debian 11. LEMP stack is an acronym for the commonly used web application and deployment component;<\/p>\n","protected":false},"author":3,"featured_media":9196,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,235,928,929,304,342,253],"tags":[4102,4101,1010,4104,4103],"class_list":["post-10143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-lemp-stack","category-mariadb","category-mysql","category-nginx","category-php","category-web-servers","tag-debian-11-lemp-stack","tag-install-lemp-stack-debian-11","tag-lemp-stack","tag-mariadb-debian-11","tag-nginx-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\/10143"}],"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=10143"}],"version-history":[{"count":4,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10143\/revisions"}],"predecessor-version":[{"id":21658,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10143\/revisions\/21658"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9196"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}