Install LAMP (Apache 2.4, MySQL 5.6, and PHP 7.0) on CentOS/RHEL 7

Share It!

LAMP stands for Linux, Apache, MySQL and PHP. Few days ago PHP version 7.0 has been released. Which has many number of changes and improvements than over version 5.X. This tutorial shows how you can install an Apache2 webserver on a CentOS 7.0 server with PHP7 and MySQL support. LAMP is short for Linux, Apache, MySQL, PHP.

See Also:

  • Install PHP 7 on CentOS/RHEL 5/6/7
  • Install PHP7 on Ubuntu Server 15.10, 15.04 & 14.04 using PPA
  • Install LAMP on CentOS/RHEL 5/6
  • How to Install LAMP on CentOS/RHEL 7
  • How to Install LAMP on Ubuntu 14.04 & 15.04
  • Install LAMP

    Apache Server

    Apache (HTTPD) is the most popular web server used on Linux systems. Lets follow following steps of install Apache Server:

    Add Yum Repository:
    First install yum repositories in your system using following command:

    # rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
    # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    

    Install Apache Server
    After adding remi repository install apache using following command:

    # yum --enablerepo=remi install httpd
    

    Start Apache Service
    Now start httpd service and enable to start on boot using below commands.

    # systemctl start httpd.service
    # systemctl enable httpd.service
    

    Verify Version
    Run the following command verify the version:

    # httpd -v
    
    Server version: Apache/2.4.6 (CentOS)
    Server built:   Jan 12 2015 13:22:31
    

    MySQL

    MySQL is an open source relational database management system (RDBMS) based on Structured Query Language (SQL).

    Add Yum Repository:
    First add MySQL yum repositories in your system using following command:

    # rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    

    Install MySQL:
    Now install MySQL server and other dependency packages.

    # yum install mysql-server
    

    Start MySQL Service
    Now start MySQL service and enable to start on boot using below commands.

    # systemctl start mysqld.service
    # systemctl enable mysqld.service
    

    Set Root Password
    Apply security on mysql and also set root user password.

    # mysql_secure_installation
    

    Verify Version
    Run the following command verify the version:

    # mysql -v
    
    mysql  Ver 14.14 Distrib 5.6.28, for Linux (x86_64) using  EditLine wrapper
    

    PHP

    The PHP development team announces the immediate availability of PHP 7.0. Several bugs have been fixed. PHP 7.0.0 comes with a new version of the Zend Engine, numerous improvements and new features.

    Add Yum Repository:
    First add yum repositories in your system using following command:

    # rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    

    Install PHP7:
    Now install PHP 7 from webtatic repository using following command:

    # yum install php70w
    

    Now install required php modules. Use following command to list available modules and install it.

    # yum search php70w
    

    Now run the following command to install all required modules:

    # yum install php70w-common php70w-xml php70w-soap php70w-xmlrpc php70w-mysql
    # yum install php70w-mbstring php70w-gd php70w-mcrypt
    

    Restart Apache Service
    After installing php and other php modules restart Apache service.

    # systemctl restart httpd.service
    

    Verify Version
    Run the following command verify the version:

    # php -v
    
    PHP 7.0.0 (cli) (built: Dec  2 2015 20:42:32) ( NTS )
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    

    Open Port in Firewall

    Now open ports for http (80) and https (443) services using following command.

    # firewall-cmd --permanent --zone=public --add-service=http 
    # firewall-cmd --permanent --zone=public --add-service=https 
    # firewall-cmd --reload
    

    Enjoy it!

    Leave a Reply

    Your email address will not be published.