LAMP is a software stack designed to host web content, like websites and web apps. It’s called LAMP because it’s built on Linux (L), Apache webserver (A), a MySQL database (M), and the PHP scripting language (P).

 

LAMP is referred to as a software stack because each of the pieces builds on top of the other. Linux is your operating system, which creates the base layer. Apache sits on top of Linux because it needs Linux to operate. MySQL sits alongside Apache to store all the information it needs.

 

And PHP sits atop the stack to drive the actual display of the website, pull info from the database and create your user experience.

 

Prerequisites:

  1. A VPS running any of our OS options— CentOS 6/7, Ubuntu 16.04/18.04.
  2. A non-root, sudo-enabled user. If you only have a root user, see our SSH Tutorial for details on creating new users.

 

Ubuntu 16.04/Ubuntu 18.04

 

The easiest and fastest way to install LAMP stack in Ubuntu 16.04 is to use tasksel, a tool that installs each element of LAMP stack with a single command.

 

Tasksel is installed by default in Ubuntu 16.04, If tasksel is missing in your system, then install it by issuing following command from the terminal:

$ sudo apt-get install tasksel

 

To run tasksel from the command line, type:

$ sudo tasksel 

 

Now tick LAMP Server and press the Tab key once, followed by the Enter key. You will be prompted to provide a root password for MySQL, and once you’ve done that, the installation will be completed within a few minutes.

 

Find the versions of Apache, MySQL, and PHP by issuing the following three commands from the terminal.

$ apache2 -v

Server version: Apache/2.4.18 (Ubuntu)

Server built:   2018-04-18T14:53:04

$ mysql -V

mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper

$ php -v

PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )

Copyright (c) 1997-2017 The PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

    with Zend OPcache v7.0.30-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

 

CentOS 6/CentOS 7

 

You need to install each element of LAMP stack separately in CentOS 6/CentOS 7, since the packages are not grouped like they are in Ubuntu.

 

Before proceeding with the installation of a LAMP stack in CentOS 6/CentOS 7, update your system using the following yum command.

$ sudo yum update && sudo yum upgrade

 

CentOS 7 enables a firewall by default, and if it is running in your system, open up port number 80using firewall-cmd. Opening port 80 will allow web traffic to pass through the firewall. You need the following steps only if your VPS is running CentOS 7.

$ sudo firewall-cmd --zone=public --permanent --add-service=http
$ sudo firewall-cmd --reload

 

Apache

 

Now install each element of the LAMP stack one by one. To start, install Apache by issuing the following command in the terminal:

$ sudo yum install httpd

 

Next, enable Apache to start automatically during system boot. The steps are different for CentOS 6 and CentOS 7.

 

In CentOS 6:

$ sudo chkconfig httpd on
$ sudo service httpd start

 

In CentOS 7:

$ sudo systemctl enable httpd.service
$ sudo systemctl start httpd.service

 

MySQL

 

Install MySQL server using following yum command and start it. Optionally, you can run mysql_secure_installation to make it secure and enable it during system boot.

 

In CentOS 6:

$ sudo yum install mysql-server
$ sudo service mysqld start
 sudo mysql_secure_installation
$ sudo chkconfig mysqld on

 

In CentOS 7:

$ sudo yum install mariadb-server
$ sudo systemctl start mariadb
$ sudo mysql_secure_installation
$ sudo systemctl enable mariadb

 

PHP

 

The default repository of CentOS contains PHP 5, which is fine for some purposes, but many will want to install the more recent and improved PHP version 7. To install PHP 7, you need to add a new repository to your CentOS installation.

 

In CentOS 6:

$ sudo yum install epel-release yum-utils
$ sudo yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

 

In CentOS 7:

$ sudo yum install epel-release yum-utils
$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

 

Now enable the remi repository using yum-config-manager before moving forward with the installation of PHP 7, along with few other popular PHP modules. Type in the following commands on both CentOS 6 and CentOS 7.

$ sudo yum-config-manager --enable remi-php72
$ sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql

 

Once the installation of PHP 7 is done, restart Apache to apply new settings:

 

In CentOS 6:

$ sudo service httpd restart

 

In CentOS 7:

$ sudo systemctl restart httpd.service

 

You can also list all available PHP modules using the following command and then install the required modules one by one.

$ sudo yum search php-

 

Find the installed version of each element of the LAMP stack using the following commands:

$ httpd -v
$ php -v
$ mysql -V

 

Test your new LAMP stack installation

 

To test the installation of LAMP stack, create a phpinfo file inside the root directory of Apache, which is /var/www/html.

$ cd /var/www/html
$ sudo echo "<?php echo phpinfo();?>" > info.php

 

Point your favourite web browser to http://IP_ADDRESS/info.php. You can view the PHP version, system information, build date, and more. Seeing this page load confirms that the LAMP stack installation was successful.

 

 

LAMP is perfect for hosting WordPress sites. So if you’re ready to set up one, just get started with our VPS! We have distinct VPS services, such as Cloud VPS, KVM VPS, Storage VPS, High RAM VPS, Managed VPS, SSD VPS and much more. 

 

Know more: https://www.ucartz.com/buy-vps-cloud-kvm-ucartz

Hai trovato utile questa risposta? 0 Utenti hanno trovato utile questa risposta (0 Voti)