{"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
This guide presents a quick way to install LEMP<\/a> Stack on Debian 11.<\/p>\n\n\n\n LEMP stack is an acronym for the commonly used web application and deployment component;<\/p>\n\n\n\n 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 If you have not installed it already, see the link below on how to install Debian 11 on VirtualBox.<\/p>\n\n\n\n Install Debian 11 on VirtualBox<\/a><\/p>\n\n\n\n To install Nginx on Debian 11, just run the command below;<\/p>\n\n\n\n When Nginx is installed, it is started and enabled to run on system boot;<\/p>\n\n\n\n To check if it is enabled to run on system boot;<\/p>\n\n\n\n If it is enabled, then the output of the command above should be enabled<\/strong>.<\/p>\n\n\n\n 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 Install MariaDB 10.6 on Debian 11<\/a><\/p>\n\n\n\n You can as well use MySQL 8<\/p>\n\n\n\n Install MySQL 8 on Debian 11<\/a><\/p>\n\n\n\n Just to confirm the version of installed of MariaDB installed;<\/p>\n\n\n\n When installed, MariaDB is started and enabled to run on system boot.<\/p>\n\n\n\n Check if it enabled to run on system boot;<\/p>\n\n\n\n Follow the links below to install your preferred PHP version.<\/p>\n\n\n\n Install PHP 7.1\/7.2\/7.3\/7.4 on Debian 11<\/a><\/p>\n\n\n\n Install PHP 8 on Debian 11<\/a><\/p>\n\n\n\n In this setup, we will use PHP 7.4.<\/p>\n\n\n\n Install Other Required PHP extensions<\/p>\n\n\n\n For any other additional PHP extension that you might need, simply get the extension name and run the command below to install it, replacing EXTENSION<\/strong> with the extension in question.<\/p>\n\n\n\n For Nginx to process PHP pages, you need to include index.php<\/strong> as a value for the index<\/strong> parameter. Since we are using the default configuration for testing, edit the it as follows;<\/p>\n\n\n\n The command above will add index.php<\/strong> to the snippet below on Also, you need to configure Nginx to pass PHP scripts to FastCGI server.<\/p>\n\n\n\n Update the following lines;<\/p>\n\n\n\n Such that they look like;<\/p>\n\n\n\n Save and exit the configuration file.<\/p>\n\n\n\n Test Nginx configuration<\/p>\n\n\n\n Restart Nginx and FastCGI process manager.<\/p>\n\n\n\n To test PHP processing, create a PHP test page under the Apache web root directory, usually, \/var\/www\/html<\/strong>, with the following content.<\/p>\n\n\n\n To test PHP processing, navigate to the browser and enter the address;<\/p>\n\n\n\n Remove the PHP test page once done.<\/p>\n\n\n\n Install and Setup OpenLDAP Server on Debian 11<\/a><\/p>\n\n\n\n\n
Installing LEMP Stack on Debian 11<\/h2>\n\n\n\n
Install Linux System<\/h3>\n\n\n\n
Install Nginx on Debian 11<\/h3>\n\n\n\n
apt install nginx<\/code><\/pre>\n\n\n\n
systemctl status nginx<\/code><\/pre>\n\n\n\n
\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
systemctl is-enabled nginx<\/code><\/pre>\n\n\n\n
Install MySQL\/MariaDB on Debian 11<\/h3>\n\n\n\n
mysql -V<\/code><\/pre>\n\n\n\n
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
systemctl status mariadb<\/code><\/pre>\n\n\n\n
\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
systemctl is-enabled mariadb<\/code><\/pre>\n\n\n\n
enabled<\/pre>\n\n\n\n
Install PHP on Debian 11<\/h3>\n\n\n\n
php -v<\/code><\/pre>\n\n\n\n
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
apt install php-fpm php-mysql<\/code><\/pre>\n\n\n\n
apt install php-EXTENSION<\/code><\/pre>\n\n\n\n
Configure Nginx for PHP Processing<\/h3>\n\n\n\n
sed -i 's|\\tindex index.html|\\tindex index.php index.html|' \/etc\/nginx\/sites-enabled\/default<\/code><\/pre>\n\n\n\n
\/etc\/nginx\/sites-enabled\/default<\/code><\/strong>.<\/p>\n\n\n\n
...\n root \/var\/www\/html;\n\n # Add index.php to the list if you are using PHP\n index index.php<\/strong> index.html index.htm index.nginx-debian.html;\n...<\/code><\/pre>\n\n\n\n
\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
# pass PHP scripts to FastCGI server\n 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
nginx -t<\/code><\/pre>\n\n\n\n
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
systemctl restart nginx php7.4-fpm<\/code><\/pre>\n\n\n\n
Test PHP Processing<\/h3>\n\n\n\n
echo '<?php phpinfo();' > \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n
http:\/\/<server-IP>\/test.php<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
rm -rf \/var\/www\/html\/test.php<\/code><\/pre>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n