linux lamp server install

How To Install LAMP (Linux, Apache, Mysql, PHP)

How to Install LAMP (Linux, Apache, MySQL, PHP) stack is open-source software that can be used for hosting websites and applications. It’s a combination of Apache, MySQL Server, and PHP scripting language. We can install the LAMP server in Centos Linux.

Install Apache

We’re going to install the Apache webserver on Redhat 6/7 version and follow the below steps to install it. I’m assuming you have yum configured on the RedHat server.

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

Check Out: Features of Redhat 8 Beta Version Recently Released

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 a widely used MySQL server in the world. This is originally made by the developer of MySQL. That’s well known as the MariaDB server in RedHat/CentOS 6/7 version.

Check Out: How To Send Root Mail To existing User

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

Installation of MariaDB Server

The first thing is to do the check packages 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 using 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 the command.

systemctl start mariadb

install lamp

Check Out: Configure Varnish For Apache Web Server

systemctl enable mariadb

 lamp server linux

Install PHP

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

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

For PHP, you must have a web server installed on your system e.g Apache or Nginx, etc.

Packages required

  1. Php
  2. Php-MySQL # MySQL Server, you can use 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

Check Out: How To Install Java Using Apt-Get Command In Ubuntu

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

  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 a web server installed on the 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();

?>

 linux lamp server

and save the file

Check Out: How To Install Memcached Memory Caching In Linux

Step 3: Now restart the Apache server service so

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 successfully installed and working. so

That’s it. linux lamp server install

LEAVE A REPLY

Please enter your comment!
Please enter your name here