Install LAMP (Linux Apache MySQL and PHP) phpMyAdmin on CentOS 6 7

LAMP represents a full featured stack of the most popular web server, database, web programming language known as Apache, MySQL and PHP. This article will cover the steps on how to install the LAMP on a CentOS 6 and CentOS 7.

1. make sure your system is up to date.

1
yum update -y

2. install Apache and add Apache to your system’s startup.

Apache is available as a package in the official Cent-OS repositories. The installation of Apache can be as easy as this.

1
2
yum install httpd -y
chkconfig --levels 235 httpd on

3. check your Apache installation.

1
service httpd start

Open your domain in web browser you will be able to see Apache’s default page in your browser. If you are testing the installing without a domain, use the server IP instead. To find your Server’s IP address, use the command below (You might need to change eth0 to match your VPS):

1
ifconfig eth0  grep inet  awk '{ print $2 }'

4. install MySQL server and add MySQL to your system’s startup.

1
2
yum install mysql-server -y
chkconfig --levels 235 mysqld on

Start MySQL and run the mysql_secure_installation script. The script will help you to set the MySQL ‘root’ password, disable remote ‘root’ login, remove anonymous users and remove the ‘test’ database.

1
2
service mysqld start
mysql_secure_installation

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL 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.

Remove test database and access to it? [Y/n] y
- 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.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL installation should now be secure.

Thanks for using MySQL!

5. install PHP as an Apache module (mod_php) so you can execute PHP scripts under your Apache web server.

1
yum install php -y

6. install PHP Modules. PHP has a variety of useful libraries and modules that you can add onto your server.

Check the libraries that are available:

1
yum search php-

The following is a list of the available PHP modules: php-bcmath => A module for PHP applications using the bcmath library php-cli => Command-line interface for PHP php-common => Common files for PHP php-dba => A database abstraction layer module for PHP applications php-devel => Files needed for building PHP extensions php-embedded => PHP library for embedding in applications php-enchant => Human Language and Character Encoding Support php-gd => A module for PHP applications using the gd graphics library php-imap => A module for PHP applications that use IMAP php-intl => Internationalization extension for PHP applications php-ldap => A module for PHP applications that use LDAP php-mbstring => A module for PHP applications which need multi-byte string handling php-mysql => A module for PHP applications that use MySQL databases php-odbc => A module for PHP applications that use ODBC databases php-pdo => A database access abstraction module for PHP applications php-pear.noarch => PHP Extension and Application Repository framework php-pecl-apc => APC cache optimizing PHP intermediate code php-pecl-memcache => Extension to work with the Memcached caching daemon php-pgsql => A PostgreSQL database module for PHP php-process => Modules for PHP scripts using system process interfaces php-pspell => A module for PHP applications using pspell interfaces php-recode => A module for PHP applications using the recode library php-snmp => A module for PHP applications that query SNMP-managed devices php-soap => A module for PHP applications that use the SOAP protocol php-tidy => Standard PHP module provides tidy library support php-xml => A module for PHP applications which use XML php-xmlrpc => A module for PHP applications which use the XML-RPC protocol php-zts => Thread-safe PHP interpreter for use with the Apache HTTP Server Install some necessary modules. For example: PHP’s common files and MySQL support for PHP

1
yum install php-cli php-common php-gd php-mysql php-mbstring

Note: php-mbstring is needed for phpMyAdmin

7. check your PHP installation.

Create a PHP info page within Apache’s document root (/var/www/html).

1
echo -e "<?php\n\tphpinfo();\n?>" > /var/www/html/info.php

Reload Apache to make the newly installed PHP module take effect.

1
service httpd restart

Now open “your domain/info.php” in web browser (http://example.com/info.php) and you should see various information page about your PHP installation.

8. install phpMyAdmin so you can easily manage your MySQL databases via a nice frontend written in PHP.

phpMyAdmin is NOT available as a package in the official Cent-OS repositories. Important: before continue the following step, go http://www.phpmyadmin.net/home\_page/downloads.php and check what is the latest version available. (At the time of writing this article the latest version of phpMyAdmin is 4.2.5. You can replace the version number in the following command.)

1
2
3
4
5
wget -P /tmp http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-4.2.5-english.tar.gz
tar -zxf /tmp/phpMyAdmin*.tar.gz -C /var/www/html/
mv /var/www/html/phpMyAdmin-4.2.5-english /var/www/html/dbAdmin
cd /var/www/html/mysql
cp config.sample.inc.php config.inc.php

Finish up by visiting your phpMyadmin: http://yourdomain/mysql

Build an extremely fast WordPress with GCP Part 1: server FREE Let's Encrypt SSL certificate via Certbot and auto renew

Comments