sudo apt-get install apache2 -y<\/pre>\nOnce installed, start and enable the service.<\/p>\n
sudo systemctl enable apache2 && sudo systemctl start apache2<\/pre>\nCheck if the service is up and running:<\/p>\n
sudo systemctl status apache2<\/pre>\nYou should receive the following output:<\/p>\n
root@host:~# sudo systemctl status apache2\r\n\u25cf apache2.service - The Apache HTTP Server\r\nLoaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\nActive: active (running) since Tue 2022-12-27 06:38:17 CST; 36min ago\r\nDocs: https:\/\/httpd.apache.org\/docs\/2.4\/\r\nMain PID: 423 (apache2)\r\nTasks: 55 (limit: 4675)\r\nMemory: 18.2M\r\nCPU: 510ms\r\nCGroup: \/system.slice\/apache2.service\r\n\u251c\u2500423 \/usr\/sbin\/apache2 -k start\r\n\u251c\u2500445 \/usr\/sbin\/apache2 -k start\r\n\u2514\u2500446 \/usr\/sbin\/apache2 -k start\r\n\r\nDec 27 06:38:17 host.test.vps systemd[1]: Starting The Apache HTTP Server...\r\nDec 27 06:38:17 host.test.vps systemd[1]: Started The Apache HTTP Server.\r\n<\/pre>\nNext, we will install PHP along with its extensions. To do that, first, add the GPG key and the repo with the following commands:<\/p>\n
apt -y install lsb-release apt-transport-https ca-certificates\r\n\r\nwget -O \/etc\/apt\/trusted.gpg.d\/php.gpg https:\/\/packages.sury.org\/php\/apt.gpg\r\n\r\necho \"deb https:\/\/packages.sury.org\/php\/ $(lsb_release -sc) main\" | tee \/etc\/apt\/sources.list.d\/php.list\r\n\r\nsudo apt-get update -y<\/pre>\nOnce the PHP key and repo are added, you can install the PHP with extensions using this long command:<\/p>\n
sudo apt-get install php8.2 php8.2-common php8.2-curl libapache2-mod-php php8.2-imap php8.2-redis php8.2-cli php8.2-snmp php8.2-xml php8.2-zip php8.2-mbstring php-gd php-xml php-mysql php-mbstring -y<\/pre>\nAfter successful installation, you can check the PHP version with the following command:<\/p>\n
php -v<\/pre>\nYou should get the following output:<\/p>\n
root@host:~# php -v\r\nPHP 8.1.13 (cli) (built: Nov 26 2022 14:27:02) (NTS)\r\nCopyright (c) The PHP Group\r\nZend Engine v4.1.13, Copyright (c) Zend Technologies\r\nwith Zend OPcache v8.1.13, Copyright (c), by Zend Technologies\r\n<\/pre>\nThe last of the LAMP stack is the MariaDB<\/b> database service. To install it execute the following command:<\/p>\nsudo apt-get install mariadb-server -y<\/pre>\nStart and enable the mariadb.service with the following commands:<\/p>\n
sudo systemctl start mariadb && sudo systemctl enable mariadb<\/pre>\nCheck the status of the mariadb.service<\/p>\n
sudo systemctl status mariadb<\/pre>\nYou should receive the following output:<\/p>\n
root@host:~# sudo systemctl status mariadb\r\n\u25cf mariadb.service - MariaDB 10.5.18 database server\r\nLoaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: enabled)\r\nActive: active (running) since Tue 2022-12-27 07:45:16 CST; 5min ago\r\nDocs: man:mariadbd(8)\r\nhttps:\/\/mariadb.com\/kb\/en\/library\/systemd\/\r\nMain PID: 43791 (mariadbd)\r\nStatus: \"Taking your SQL requests now...\"\r\nTasks: 8 (limit: 4675)\r\nMemory: 78.0M\r\nCPU: 606ms\r\nCGroup: \/system.slice\/mariadb.service\r\n\u2514\u250043791 \/usr\/sbin\/mariadbd\r\n<\/pre>\nNow, when the LAMP<\/b> stack is installed, we are ready to proceed with database creation and Drupal installation.<\/p>\n<\/span>Step 3. Create a Drupal Database and User<\/span><\/h2>\nTo create a Drupal database, the Drupal user and grant the permissions for that user to the database first log in to MySQL command line with the mysql<\/b> command and execute the following lines of code one by one:<\/p>\nCREATE USER 'drupal'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';\r\nCREATE DATABASE drupal;\r\nGRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';\r\nFLUSH PRIVILEGES;\r\nEXIT;\r\n<\/pre>\nNow, the database and user with the name drupal<\/b> have been added with proper permissions. We are ready to download the Drupal installation and set the file and folder permissions.<\/p>\n