Install LAMP (linux, Apache ,Mysql ,PHP) On Redhat/CentOs 7

0
47
views

LAMP (linux , apache , mysql ,php) stack is an open source software that can be used for hosting website and applications. It’s a combination of Apache , Mysql Server And PHP scripting language.

Install Aapche

We’re going to install apache web server on Redhat 6/7 version and follow our steps to install it.I’m assuming you have Yum configured on the server.

First check apache is already installed or not. If you no output means this is not installed.

By command rpm –qa httpd*

Step 1 : Run command mentioned below

 Yum install httpd* -y

After running this command apache will be installed and check it by command mentioned below

rpm –qa  | grep –I  httpd

Step 2 : You can find the configuration file of apache at this location

/etc/httpd/conf/httpd.conf

Step 3 : Now you have to start the service of apache

Systemctl start httpd

Install Mysql / Mariadb

Mariadb is a relational database server. It’s widely used mysql server in the world. It is originaly made by developer of Mysql. It is well known as mariadb server in redhat /CentOs 6/7 version as we know if we installed mysql server the package will be the name of mysql not mariadb like in redhat 7.

It uses the port 5432 and open source database serve. The main configuration file is /etc/my.cnf

Installation of Mariadb Server

First thing to do is to check whether is already installed or not.

Rpm –qa  mariadb*

If not installed then run this command

Yum install mariadb* -y

Once it’s get installed you need to check all the dependencies are installed or not by the same command

rpm –qa mariadb*

 Packages included :

  • mysql-community-devel-5.7.22-1.el7.x86_64.rpm
  • mysql-community-libs-compat-5.7.22-1.el7.x86_64.rpm
  • mysql-community-client-5.7.22-1.el7.x86_64.rpm
  • mysql-community-test-5.7.22-1.el7.x86_64.rpm
  • mysql-community-server-5.7.22-1.el7.x86_64.rpm

Now You need to start/enable the services of Mysql Server

Run following commands to do this

systemctl start mariadb

systemctl enable mariadb

Install PHP

PHP ( hypertext preprocessor) is a widely used scripting language for web development. It is also an open source scripting language. Current version of PHP is 7.0 It was originally created by Rasmus Lerdorf in 1994.

The file extension is .php and the path of php file stored at location /var/www/html/index.php

For php there must be web server installed on your system e.g Apache or nginx etc.

Packages required

  1. Php
  2. Php-mysql # mysql Server , you can any other database server
  3. Php-gd
  4. Php-pear

Php-gd = A module for PHP applications for using the gd graphics library

Php-pear = PHP Extension and Application Repository framework

Other Packages are mentioned below you can install them according to your need

  1. OPcache (php-opcache)
  2. APCu (php-pecl-apcu)
  3. CLI (php-cli)
  4. PDO (php-pdo)
  5. PostgreSQL (php-pgsql)
  6. MongoDB (php-pecl-mongodb)
  7. Redis (php-pecl-redis)
  8. Memcache (php-pecl-memcache)
  9. MCrypt (php-mcrypt)
  10. XML (php-xml)

Step 1: Install PHP using Yum

Note : Must  have web server installed on machine

yum install php php-mysql.x86_64 php-gd.x86_64 php-pear.noarch  –y

Step 2: Now create a test file under the directory /var/www/html/test.php

Put these line in the file test.php

<?php

Phpinfo();

?>

And save the file

Step 3: Now restart the apache server service

Systemctl restart httpd

Now go to the browser type http://192.168.184.177/test.php replace IP with your or run on localhost http://localhost/test.php

You will see this page if php is successfully installed and working.

You’re done 

LEAVE A REPLY

Please enter your comment!
Please enter your name here