yum is located in /etc/yum.repos.d/
files have .repo extension to be recognized by YUM

$ sudo yum update
$ sudo systemctl status firewalld
$ sudo systemctl start firewalld
$ sudo systemctl enable firewalld
$ sudo systemctl stop firewalld

add service or custom port to to exclude from firewall

$ sudo firewall-cmd –permanent –add-service=http
$ sudo firewall-cmd –permanent –add-service=https
$ sudo firewall-cmd –permanent –add-service=mysql
$ sudo firewall-cmd –permanent –add-service=ntp
$ sudo firewall-cmd –permanent –add-port=8080/tcp
$ sudo firewall-cmd –permanent –add-port=4444/tcp
$ sudo firewall-cmd –permanent –add-port=4567/tcp
$ sudo firewall-cmd –permanent –add-port=4568/tcp
$ sudo firewall-cmd –permanent –add-port=139/tcp
$ sudo firewall-cmd –permanent –add-port=445/tcp
$ sudo firewall-cmd –reload
$ sudo systemctl restart firewalld.service
$ sudo iptables -L

4444, 45467, 4568 is for percona (if you need any), 139, 445 is for samba, 8080 is for https

i.e. test mysql access from remote machine (do this after mysql installation)

$ sudo mysql -h -u msen -p


Let’s assume our local ip is:

To learn hostname, get local ip, get public ip, get public ip in details

$ hostname
$ ip addr show
$ ip addr show eth0
$ ip addr show eth0 | grep inet | awk ‘{ print $2; }’ | sed ‘s/\/.*$//‘


print kernel release, print kernel name

$ uname -r
$ uname -s


select your OS to get the latest MariaDB repo

you can rename a similar name to MariaDB

$ sudo vi /etc/yum.repos.d/MariaDB.repo

copy paste this to MariaDB.repo:

# MariaDB 10.0 CentOS repository list – created 2015-07-09 14:56 UTC
name = MariaDB
baseurl =

finally update yum

$ sudo yum update

NTP (skip this if you don’t need to sync servers)

install ntp (network time protocol) server to synchronize time

$ sudo yum install ntp

first go to official
choose your Continent area where the server physically is located, then search for your Country location
For United Sates:


go to ntp config file

$ sudo vi /etc/ntp.conf

only local network can synchronize time with this server, edit like this

restrict mask nomodify notrap

Uncomment initials:

#server iburst
#server iburst
#server iburst
#server iburst

copy new United States to config and start

$ sudo systemctl start ntpdate
$ sudo systemctl enable ntpdate
$ sudo systemctl status ntpdate

run this

$ sudo ntpdate


if you need to check out all the services

$ sudo systemctl list-units –type=service

or you can search a specific service

$ sudo systemctl list-units –type=service | grep at\..*service

So we are ready now to install LAMP on Centos 7

1- Install Apache

Install Apache Web Server

to start, enable, check status, restart gracefully, restart and see the version of apache

$ sudo yum install httpd
$ sudo systemctl start httpd.service
$ sudo systemctl enable httpd.service
$ sudo systemctl status httpd.service
$ sudo apachectl graceful
$ sudo systemctl restart httpd.service
$ httpd -v

Apache Config

Setup Apache config, add ServerName followed by ip:80

$ sudo vi /etc/httpd/conf/httpd.conf

to test apache configuration before restarting

$ sudo apachectl configtest

check out apache web with your local or public ip

2- Install MariaDB (MySQL)

Remove if existing 5.5 MariaDB

remove preversion of mariadb, clean up the repository cache, install, start, enable, run security script, check status and upgrade if necessary

$ sudo yum remove mariadb-server mariadb-libs
$ yum clean all
$ sudo yum install MariaDB-server MariaDB-client
$ sudo systemctl start mysql
($ sudo /etc/init.d/mysql start)
$ sudo systemctl enable mysql
$ sudo mysql_secure_installation
$ sudo systemctl status mysql
$ sudo mysql_upgrade -u root -p

login database

$ sudo mysql -u root -p
mysql>show databases;

main config file

$ sudo vi /etc/my.cnf

if it’s not there ask mysqld where it looks for its config

$ /usr/libexec/mysqld –help –verbose

3- Install PHP


$ sudo yum install php php-mysql

search optional php packages, run almost all packages, you can also get info of a certain package i.e php-mysql

$ sudo yum search php-
$ sudo yum install php-gd php-pear php-mbstring php-pgsql php-fmp php-ldap php-devel php-pspell php-intl php-xml php-xmlrpc php-soap php-bcmath php-snmp php-embedded php-pecl-memcache php-odbc php-curl
$ sudo yum info php-mysql

test php

$ sudo vi /var/www/html/info.php

write this

<?php  phpinfo(); ?>

restart apache and remove info.php later if in prod

$ sudo systemctl restart httpd.service
$ sudo rm /var/www/html/info.php

to change max file upload size

$ sudo vi /etc/php.ini
upload_max_filesize = 100M

test database from php

$ sudo vi /var/www/html/dbtest.php

copy paste this:

$con = mysql_connect("localhost","root","YourPassword");
if (!$con){
   die('Could not connect: ' . mysql_error());
    echo "Congrats! connection established successfully";

4- Install PhpMyAdmin

To install phpMyAdmin easily on CentOS 7, first install extra packages for enterprise linux (epel), then install phpMyAdmin

$ sudo yum install epel-release
$ sudo yum install phpMyAdmin

edit conf file

$ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf

to access only from certain ip
put Require ip under each Require ip

or disable first block and add this

<Directory /usr/share/phpMyAdmin/>
         Options none
         AllowOverride Limit
         Require all granted

finally restart apache

$ sudo systemctl restart httpd.service

Now check out PhpMyAdmin

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s