<\/span><\/h2>\n\n\n\nFirst part of installing the LAMP stack will be the Apache web server. To install it, execute the following command:<\/p>\n\n\n\n
sudo apt install apache2 -y<\/pre>\n\n\n\nOnce installed, start and enable the service.<\/p>\n\n\n\n
sudo systemctl enable apache2 && sudo systemctl start apache2<\/pre>\n\n\n\nCheck if the service is up and running:<\/p>\n\n\n\n
sudo systemctl status apache2<\/pre>\n\n\n\nYou should receive the following output:<\/p>\n\n\n\n
root@host:~# sudo systemctl status apache2\n\u25cf apache2.service - The Apache HTTP Server\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n Active: active (running) since Fri 2023-10-19 04:50:18 CDT; 1s ago\n Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n Process: 50686 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=0\/SUCCESS)\n Main PID: 50690 (apache2)\n Tasks: 6 (limit: 4558)\n Memory: 10.0M\n CPU: 203ms\n CGroup: \/system.slice\/apache2.service\n<\/pre>\n\n\n\nNext is PHP with its extensions. To install PHP 8.1 completely, execute the following command:<\/p>\n\n\n\n
sudo apt-get install php8.1 php8.1-cli php8.1-common php8.1-imap php8.1-redis php8.1-snmp php8.1-xml php8.1-zip php8.1-mbstring php8.1-curl php8.1-mysqli php8.1-gd php8.1-intl php8.1-apcu libapache2-mod-php -y\n<\/pre>\n\n\n\nTo check the installed PHP version, execute the following command, php -v<\/b>:<\/p>\n\n\n\nroot@host:~# php -v\nCreated directory: \/var\/lib\/snmp\/cert_indexes\nPHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)\nCopyright (c) The PHP Group\nZend Engine v4.1.2, Copyright (c) Zend Technologies\n with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies\n<\/pre>\n\n\n\nThe last component of the LAMP stack is the MariaDB (or MySQL) database server. To install the MariaDB database server, execute the command below.<\/p>\n\n\n\n
sudo apt install mariadb-server -y<\/pre>\n\n\n\nStart and enable the mariadb.service with the following commands:<\/p>\n\n\n\n
sudo systemctl start mariadb && sudo systemctl enable mariadb<\/pre>\n\n\n\nCheck the status of the mariadb.service<\/p>\n\n\n\n
sudo systemctl status mariadb<\/pre>\n\n\n\nYou should receive the following output:<\/p>\n\n\n\n
root@host:~# sudo systemctl status mariadb\n\u25cf mariadb.service - MariaDB 10.6.12 database server\n Loaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: enabled)\n Active: active (running) since Fri 2023-10-19 04:58:18 CDT; 22s ago\n Docs: man:mariadbd(8)\n https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\n Main PID: 55172 (mariadbd)\n Status: \"Taking your SQL requests now...\"\n Tasks: 15 (limit: 4558)\n Memory: 61.2M\n CPU: 1.921s\n CGroup: \/system.slice\/mariadb.service\n \u2514\u250055172 \/usr\/sbin\/mariadbd\n<\/pre>\n\n\n\n