Installation of Lamp Stack on CentOS 7

Installation of Lamp Stack on CentOS 7

Publisher: Psychz Networks, January 24,2019

A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used to prepare servers for hosting web content. Following steps will shows you how to install a LAMP stack on a Virtual Private Server (VPS). LAMP is an archetypal model of web service stacks. It stands for four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language.

In this scenario the virtual private server is already running CentOS 7, the Linux part is taken care of. Here is how to install the rest.

Installation Steps:

The first and foremost task that we should perform is to update the latest packages. This can be achieved by an ‘update’ command that would take a few minutes to compile. ‘yum’ will automatically attempt to check all configured repositories to resolve all package dependencies during an installation/upgrade.

It is important to make sure that the latest software updates and bug fixes are installed. The command is as follows:

Installation of MariaDB on CentOS 7 server

MariaDB is an enhanced replacement for MySQL server in CentOS 7 environment. MariaDB is developed by the community in true open source spirit. A secure and scalable database server for scale-up or scale-out deployments, built on a modern extensible architecture that supports innovation.

The command to install MariaDB is as follows:

sudo yum install mariadb-server

Press y when prompted to proceed with the installation.

Use the following command to start MariaDB

sudosystemctl start mariadb

Securing MariaDB:

A secure installation can be performed in which the user can set a password for access to the database. It is done by the following command:

sudo /usr/bin/mysql_secure_installation

Accessing MariaDB:

MariaDB can be accessed using the following command:

mysql –u root –p

Note: The server will ask for a password, if not set it can be skipped by pressing the Enter key.

Installation of PHP on CentOS 7

PHP (Hypertext Preprocessor) commonly used open-source general purpose scripting language that is largely suited for web development. It can also be embedded into HTML.

The installation of PHP and its modules is done using the following command:

Sudo yum install phpphp-mysqlphp-gd php-pear

The output is as follows:

After the installation of PHP the httpd (Apache) service must be restarted.

The command for the following is:

sudosystemctl restart httpd

Test PHP on the server

After installation of PHP on the server we must test if it’s functioning properly. Following are the corresponding steps: