Professional Documents
Culture Documents
LAMP is a combination of operating system and open-source software stack. The acronym of LAMP
is derived from first letters ofLinux, Apache HTTP Server, MySQL/MariaDB database,
andPHP/Perl/Python.
In this tutorial, let us see how to setup LAMP server on RHEL/CentOS/Scientific Linux 7.
Install Apache
Apache is an open-source multi-platform web server. It provides a full range of web server features
including CGI, SSL and virtual domains.
Start the Apache service and make it to start automatically on every reboot:
If you’re behind firewall or router, allow Apache server through your firewall/router in case you want
to access it from the remote systems. To do that, enter the following commands from your Terminal:
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 1/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Test Apache
Open your web browser and navigate to http://localhost/ orhttp://server-ip-address/.
Install MariaDB
MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that
comes rich set of enhancements.
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 3/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Remove test database and access to it? [Y/n] y ## Enter Y and press Enter
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Install PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general
purpose scripting language that is especially suited for web development and can be embedded into
HTML.
Test PHP:
Create a sample “testphp.php” file in Apache document root folder and append the lines as shown
below:
vi /var/www/html/testphp.php
<?php
phpinfo();
?>
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 4/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Navigate to http://server-ip-address/testphp.php. It will display all the details about php such
as version, build date and commands etc.
If you want to install all php modules, enter the command yum install php* -y and restart the httpd
service. To verify for the modules, open web browser and navigate to http://server-ip-
address/testphp.php. You will then see all php modules.
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 5/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Configure phpMyAdmin
By default, phpMyAdmin can only be accessed from the localhost itself. To make it to accessible
globally, do the following steps.
vi /etc/httpd/conf.d/phpMyAdmin.conf
Find and comment the whole /<Directory> section and add the lines as shown below:
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#<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>
<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 6/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
[...]
Edit “config.inc.php” file and change from “cookie” to “http” to change the authentication in
phpMyAdmin:
vi /etc/phpMyAdmin/config.inc.php
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or c
ookie based)?
[...]
Now you can access the phpmyadmin console by navigating to the URL http://server-ip-
address/phpmyadmin/ from your browser.
Enter your MySQL username and password which you have given in previous steps. In my case its
“root” and “centos”.
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 7/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Now you will able to manage your MariaDB databases from phpMyAdmin web interface.
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 8/9
8/27/2014 Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 | Unixmen
Cheers!
http://www.unixmen.com/install-lamp-server-apache-mariadb-php-centosrhelscientific-linux-7/ 9/9