Skip to content

Instantly share code, notes, and snippets.

@Igor-Lopes
Created May 1, 2017 05:10
Show Gist options
  • Save Igor-Lopes/de9c401edde634db44fcac5a4256a626 to your computer and use it in GitHub Desktop.
Save Igor-Lopes/de9c401edde634db44fcac5a4256a626 to your computer and use it in GitHub Desktop.
Install LAMP on CentOS/RHEL/ 7

Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/ 7

Install Apache:

yum install httpd -y

Start the Apache service and make it to start automatically on every reboot:

systemctl start httpd

systemctl enable httpd

Allow Apache server through firewall/router:

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

systemctl restart firewalld

Test Apache:

http://localhost/ or http://server-ip-address

You should see Apache default page.

Install MariaDB

yum install mariadb-server mariadb -y

Start MariaDB service and make it to start automatically on every reboot:

systemctl start mariadb

systemctl enable mariadb

Set MySQL root password:

mysql_secure_installation

Install PHP

yum install php php-mysql php-gd php-pear -y

Test PHP:

nano /var/www/html/phpinfo.php then add:

<?php 
phpinfo(); 
?>

Restart httpd service:

systemctl restart httpd

Test php by accessing phpinfo.php:

http://localhost/phpinfo.php or http://server-ip-address/phpinfo.php

Install phpMyAdmin:

First install EPEL Repository: yum install epel-release then install phpMyAdmin: yum install phpmyadmin -y

Make phpMyAdmin to accessible globally:

Access phpMyAdmin conf file: nano /etc/httpd/conf.d/phpMyAdmin.conf

Find and comment the whole / section and add the lines as shown below:

[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

## Comment the following Section ##

#<Directory /usr/share/phpMyAdmin/>
#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     <RequireAny>
#       Require ip 127.0.0.1
#       Require ip ::1
#     </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>

## Add the following lines:

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

Edit “config.inc.php” file and change from “cookie” to “http” to change the authentication in phpMyAdmin:

nano /etc/phpMyAdmin/config.inc.php then Change ‘cookie’ to ‘http’:

[...] 
/* Authentication type */
$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)?
[...]

Restart the Apache service:

systemctl restart httpd

Access phpMyAdmin with mysql credentials:

http://localhost/phpmyadmin or http://server-ip-address/phpmyadmin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment