How to LAMP on CentOS 7 with phpMyAdmin

 LAMP stands for Linux, Apache, MySQL and PHP.

If you’re trying to build a web application using PHP you’ll need a server and installing the required applications on it. Collectively called LAMP, we’ll be installing the required applications on a Centos 7 Cloud Server and run a WordPress blog on it in later posts.

====== LAMP on CentOS 7 ======

update system

sudo yum update

check firewall status

sudo systemctl status firewalld

if firewall is not running, run it

sudo systemctl start firewalld

enable firewall to start on boot

sudo systemctl enable firewalld

allow HTTP and HTTPS services through firewall

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https

to open port through firewall

firewall-cmd --permanent --add-port=80/tcp

to check status of opened ports

firewall-cmd --list-all

reload for above rules for them to take effect

sudo firewall-cmd --reload

install APACHE module

sudo yum install httpd

start APACHE

sudo systemctl start httpd.service

to start APACHE on boot up

sudo systemctl enable httpd.service

check status of APACHE

sudo systemctl status httpd.service

check APACHE config status

sudo apachectl configtest

to restart APACHE

systemctl restart httpd.service

to install MariaDB

sudo yum install mariadb-server mariadb

start MariaDB

sudo systemctl start mariadb

setting up MariaDB

sudo mysql_secure_installation

check MariaDB status

sudo systemctl status mariadb

to enable MariaDB statup on boot

sudo systemctl enable mariadb.service

To install PHP on CentOS 7

Enable required repo

yum install epel-release yum-utils -y

download and install required repo

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

based on which php version is needed

yum-config-manager --enable remi-php71

install enabled version

yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql -y

to check its working

sudo nano /var/www/html/info.php

FILE: info.php

<?php
phpinfo();
?>

restart apache for changes to take effect

sudo systemctl restart httpd.service

check php version

php -v

to remove file

sudo rm /var/www/html/info.php

to install phpMyAdmin add EPEL repository

sudo yum install epel-release

install phpMyAdmin

sudo yum install phpmyadmin

to allow outside ip to connect to phpmyadmin

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

File: phpMyAdmin.conf

 <Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
      #Require ip 127.0.0.1
      #Require ip ::1
      Require all granted
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

restart apache for changes to take effect

sudo systemctl restart httpd.service

This finishes the LAMP stack installation on a CentOS 7 Server. Same could also be used on CentOS 8 as well.

Next Post Previous Post
No Comment
Add Comment
comment url