sudo apt-get install apache2<\/pre>\nOnce the installation is complete, enable the Apache service to start automatically upon system boot. You can do that with the following command:<\/p>\n
sudo systemctl enable apache2<\/pre>\nTo verify that Apache is running, execute the following command:<\/p>\n
sudo systemctl status apache2<\/pre>\nOutput:<\/p>\n
\u25cf apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Mon 2019-05-27 14:13:39 EDT; 6s ago\r\n Main PID: 7812 (apache2)\r\n CGroup: \/system.slice\/apache2.service\r\n \u251c\u25007812 \/usr\/sbin\/apache2 -k start\r\n \u251c\u25007814 \/usr\/sbin\/apache2 -k start\r\n \u2514\u25007815 \/usr\/sbin\/apache2 -k start<\/pre>\n<\/span>Step 3: Install MariaDB<\/span><\/span><\/h2>\nThe next step is to install the MariaDB database server.<\/p>\n
To install MariaDB on your system, type the following command and enter the character \u2018Y\u2019 when prompted:<\/p>\n
sudo apt-get install mariadb-server<\/pre>\nDuring the installation, you will be asked to enter a password for the MariaDB root user. Make sure to enter a strong password.<\/p>\n
To further improve the security of our MariaDB installation as well as set up a password for our MariaDB root user, we need to run the\u00a0mysql_secure_installation<\/strong>\u00a0script and follow the on-screen instructions. Run the command below to configure your system:<\/p>\nsudo mysql_secure_installation<\/pre>\nIf the program asks you to enter your current MariaDB root password, just press your [Enter] key once, as no password is set by default when installing MariaDB. Alternatively, if you did set a password earlier when installing MariaDB, enter that one.<\/p>\n
A few more questions will be displayed on-screen \u2013 it is recommended that you answer yes to all of them by entering the character \u2018Y\u2019:<\/p>\n
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y\r\nDisallow root login remotely? (Press y|Y for Yes, any other key for No) : Y\r\nRemove test database and access to it? (Press y|Y for Yes, any other key for No) : Y\r\nReload privilege tables now? (Press y|Y for Yes, any other key for No) : Y<\/pre>\nAgain, we can enable MariaDB to start on boot with the following command:<\/p>\n
sudo systemctl enable mariadb<\/pre>\nThat\u2019s it \u2013 MariaDB has been installed and made more secure.<\/p>\n
<\/span>Step 4: Install PHP<\/span><\/span><\/h2>\nThe last step of our LAMP stack setup is to install PHP. Debian 9 comes with PHP 7.0 by default, but it is recommended to use the stable version of PHP which is PHP version 7.2. In order to do this, we’ll install a third-party repository that has the latest PHP environment for Debian 9.<\/p>\n
To proceed, use the following commands:<\/p>\n
sudo apt install apt-transport-https lsb-release ca-certificates\r\nsudo wget -O \/etc\/apt\/trusted.gpg.d\/php.gpg https:\/\/packages.sury.org\/php\/apt.gpg\r\nsudo sh -c 'echo \"deb https:\/\/packages.sury.org\/php\/ $(lsb_release -sc) main\" > \/etc\/apt\/sources.list.d\/php.list'\r\nsudo apt-get update<\/pre>\nAfter updating the repository, use the following command to install PHP 7.2 and all PHP extensions required by Zabbix:<\/p>\n
apt-get install php7.2 libapache2-mod-php7.2 php7.2-cli php7.2-mysql php7.2-common php7.2-ldap php7.2-zip php7.2-bcmath php7.2-mbstring php7.2-curl php7.2-soap php7.2-gd php7.2-xml php7.2-cgi<\/pre>\nTo verify the PHP version installed, supply the following command:<\/p>\n
php\u00a0-v<\/pre>\nThe following output should be displayed on your screen:\r\n\r\nPHP 7.2.18-1+0~20190503103213.21+stretch~1.gbp101320 (cli) (built: May 3 2019 10:32:13) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\n with Zend OPcache v7.2.18-1+0~20190503103213.21+stretch~1.gbp101320, Copyright (c) 1999-2018, by Zend Technologies\r\n<\/pre>\n<\/span>Step 5: Install Zabbix<\/span><\/span><\/h2>\nWe can now start with our Zabbix installation and configuration.<\/p>\n
At the time of writing, the latest stable LTS version of Zabbix is 4.2. Fortunately, Zabbix provides a Debian-based repository for easier installation and updates in the future.<\/p>\n
To download and install the latest version of the Zabbix repository, run the following commands:<\/p>\n
wget https:\/\/repo.zabbix.com\/zabbix\/4.2\/debian\/pool\/main\/z\/zabbix-release\/zabbix-release_4.2-1+stretch_all.deb\r\ndpkg -i zabbix-release_4.2-1+stretch_all.deb\r\napt update<\/pre>\nAfter successfully updating the repositories and packages, we can now install the Zabbix package which includes the MySQL and PHP packages for Zabbix, as well as the Zabbix Agent.<\/p>\n
apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent<\/pre>\n<\/span>Step 6: Configure the Database<\/span><\/span><\/h2>\nNext, we need to create a new database. To do this, log in to your MariaDB database server as the root user by typing the following command:<\/p>\n
sudo mariadb -u root -p<\/pre>\nThen enter the password you made for your MariaDB user. Once you are signed in, create a new database and user by running the following commands on the MariaDB shell:<\/p>\n
CREATE DATABASE zabbix<\/strong> character set utf8 collate utf8_bin;\r\nCREATE USER zabbix<\/strong>@localhost IDENTIFIED BY 'strong-password<\/strong><\/span>';\r\nGRANT ALL PRIVILEGES ON zabbix<\/strong>.* TO zabbix<\/strong>@localhost;\r\nFLUSH PRIVILEGES;<\/pre>\nMake sure to replace\u00a0strong-password<\/strong><\/span>\u00a0with an actual strong password.<\/p>\nTo exit the MariaDB database server command line, type:<\/p>\n
exit<\/pre>\nTo finalize the setup of the Zabbix database, we will need to import the initial schema for our Zabbix database. You can do this with the following command:<\/p>\n
zcat \/usr\/share\/doc\/zabbix-server-mysql\/create.sql.gz | mysql -u zabbix -p zabbix<\/pre>\n