LAMP is a combination of operating system and open-source software stack. The acronym LAMP came from the first letters of Linux, Apache HTTP Server, MySQL or MariaDB database, and PHP/Perl/Python. This tutorial describes how to install it on a Debian Jessie distribution, but it should work on previous version of Debian and derivatives.
1. Install Apache
Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.
To install Apache, enter:
apt-get install apache2
Open your web browser and navigate to http://localhost/ or http://server-ip-address/.
2. Install MariaDB
Under Debian systems, it’s highly recommended to install ‘python-software-properties‘ package, before heading up for the MariaDB installation from official repositories.
apt-get install python-software-properties
Next, import and regtister the GPG key, which enables apt to verify the integrity of software’s it downloads.
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
Now, add the following MariaDB official repository to your sources.list file, using the following command.
add-apt-repository 'deb http://mariadb.biz.net.id/repo/10.1/debian jessie main'
If adding repository throws error like “add-apt-repository: command not found”, you need to install ‘software-properties-common’ as shown below.
apt-get install software-properties-common
Update the list of available Packages on the system.
Finally, install MariaDB Server and Client, using the following commands.
apt-get install mariadb-server mariadb-client
If installation goes smooth, check the version of Installed MariaDB.
mysql Ver 15.1 Distrib 10.1.13-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Login to MariaDB using root (Not Recommended), followed by password.
mysql -u root -p
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 10.1.13-MariaDB-1~jessie mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
NOTE: The ‘none’ above, it means no Database is selected currently.
Important Note: In Ubuntu 15.10/15.04, MariaDB won’t ask you to set root user password during installation.
Also, you can’t set password manually using the following command too:
It will throw the following error.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ERROR 1698 (28000): Access denied for user 'root'@'localhost' Enter current password for root (enter for none):
To fix this error, log in to mysql prompt without password as root user:
mysql -u root
Then, run the following commands one by one in the mysql prompt:
update user set plugin='' where User='root';
That’s it. Now, set database administrative “root” user password using command. Press Enter and go with the default settings.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Check if mariadb is running or not, using the following command:
service mysql status
● mariadb.service - MariaDB database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled) Drop-In: /etc/systemd/system/mariadb.service.d └─migrated-from-my.cnf-settings.conf Active: active (running) since lun 2016-04-11 11:13:16 EDT; 22min ago Main PID: 25965 (mysqld) Status: "Taking your SQL requests now..." CGroup: /lxc/410/system.slice/mariadb.service abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140007725565696 [Note] InnoDB: Dumping buffer pool(s) not yet started abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140008488851392 [Note] Plugin 'FEEDBACK' is disabled. abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140008488851392 [Note] Server socket created on IP: '127.0.0.1'. abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140008488851392 [Note] Reading of all Master_info entries succeded abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140008488851392 [Note] Added new Master_info '' to hash table abr 11 11:13:16 nagios-master mysqld: 2016-04-11 11:13:16 140008488851392 [Note] /usr/sbin/mysqld: ready for connections. abr 11 11:13:16 nagios-master mysqld: Version: '10.1.13-MariaDB-1~jessie' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution abr 11 11:13:16 nagios-master mysqld: Checking for corrupt, not cleanly closed and upgrade needing tables. abr 11 11:13:16 nagios-master /etc/mysql/debian-start: Upgrading MySQL tables if necessary. abr 11 11:13:16 nagios-master systemd: Started MariaDB database server.
3. Install PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.
Install PHP with following command:
apt-get install php5 php5-mysql libapache2-mod-php5
To test PHP, create a sample “testphp.php” file in Apache document root folder.
Add the following lines:
<?php phpinfo(); ?>
Restart apache2 service.
systemctl restart apache2
Navigate to http://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.
If you want to install all php modules at once, enter the command sudo apt-get install php* and restart the apache2 service. To verify the modules, open web browser and navigate to http://server-ip-address/testphp.php. You will able to see all installed php modules.
I know my strengths and weaknesses. I'm a quick learner, I know how to work with small and big teams. I'm hard worker, proactive and I achieve everything I propose.
Latest posts by Pablo Javier Furnari (see all)
- Create our own plugins for Check_MK and WATO - July 26, 2017
- Install Nagios Core 4.3.2 in Debian Stretch Part 2 - July 26, 2017
- Install Nagios Core 4.3.2 in Debian Stretch Part 1 - July 25, 2017