<\/span><\/h2>\nIn this section, we will show you how to install the LAMP stack on your VPS. If you already have LAMP\/LEMP installed you can skip this part and proceed with the next step of the tutorial.<\/p>\n
First, let’s install the Apache web server. We can do this by running the following command:<\/p>\n
apt install apache2<\/pre>\nAfter the installation is completed, start Apache and enable it to start automatically after a reboot with:<\/p>\n
systemctl start apache2\r\nsystemctl enable apache2<\/pre>\nTo check and verify whether Apache is currently running on your server, execute the following command:<\/p>\n
systemctl status apache2<\/pre>\nOutput:<\/p>\n
\u25cf apache2.service - The Apache HTTP Server\r\nLoaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\nDrop-In: \/lib\/systemd\/system\/apache2.service.d\r\n \u2514\u2500apache2-systemd.conf\r\nActive: active (running) since Sat 2019-01-26 02:20:44 CST; 1h 57min ago\r\nMain PID: 14666 (apache2)\r\nTasks: 7 (limit: 2320)\r\nCGroup: \/system.slice\/apache2.service\r\n \u251c\u2500 504 \/usr\/sbin\/apache2 -k start\r\n \u251c\u250014666 \/usr\/sbin\/apache2 -k start\r\n \u251c\u250014686 \/usr\/sbin\/apache2 -k start\r\n \u251c\u250014687 \/usr\/sbin\/apache2 -k start\r\n \u251c\u250014688 \/usr\/sbin\/apache2 -k start\r\n \u251c\u250014689 \/usr\/sbin\/apache2 -k start\r\n \u2514\u250014690 \/usr\/sbin\/apache2 -k start<\/pre>\nNext, we need to install the MySQL web server. The following command will install the latest MySQL 5.7 server from the official Ubuntu repositories:<\/p>\n
apt install mysql-server<\/pre>\nOnce the installation is complete, issue the following command to secure your installation:<\/p>\n
mysql_secure_installation<\/pre>\nYou will be prompted to answer several questions:<\/p>\n
Setup VALIDATE PASSWORD plugin? (Press y|Y for Yes, any other key for No) N<\/strong>\r\nChange root password? (Press y|Y for Yes, any other key for No) N<\/strong>\r\nRemove anonymous users? (Press y|Y for Yes, any other key for No) Y<\/strong>\r\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) Y<\/strong>\r\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) Y<\/strong>\r\nReload privilege tables now? (Press y|Y for Yes, any other key for No) Y<\/strong><\/pre>\nThe last step of our LAMP stack setup is the PHP installation. Currently, the default PHP version available at the official Ubuntu repository is PHP 7.2.<\/p>\n
To install PHP 7.2 on your server along with several PHP extensions, run the following command:<\/p>\n
apt install -y php php-common php-mbstring php-gd php-intl php-xml php-mysql php-mcrypt<\/pre>\nTo verify if PHP is properly installed, you can run the following command:<\/p>\n
php -v<\/pre>\nOutput:<\/p>\n
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\nwith Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies<\/pre>\nWe now have a fully working LAMP stack running on our server. We are now ready to proceed to the next step of this tutorial and begin the MyWebSQL installation.<\/p>\n