GNU/Linux LAMP Stack Installing LAMP stack on CentoOS


Example

Install Apache Web Server

First step is to install web server Apache.

sudo yum -y install httpd

Once it is installed, enable (to run on startup) and start Apache web server service.

sudo systemctl enable --now httpd

Point your browser to:

http://localhost

You will see the default Apache web server page.

Install MariaDB Server

Second step is to install MariaDB:

sudo yum -y install mariadb-server

Then start and enable (on startup) the MariaDB server:

sudo systemctl enable --now mariadb

As needed, use mysql_secure_installation to secure your database.

This script will allow you to do the following:

  • Change the root user's password
  • Remove test databases
  • Disable remote access

Install PHP

sudo yum -y install php php-common

Then restart Apache's httpd service.

sudo systemctl restart httpd

To test PHP, create a file called index.php in /var/www/html.

Then add the following line to the file:

Then point your browser to:

http://localhost/index.php

You should see information related to your server. If you do not, ensure that php is for sure installed correctly by running the following command:

php --version

If you receive something like:

PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02) Copyright (c) 1997-2013 The PHP Group

Then PHP is installed correctly. If this is the case, please ensure that you've restarted your web server.