Apache, PHP and MySQL is an open source web based software's and the world's most widely used it.  ​This post will demonstrate how to install httpd server, PHP and MySQL database on a CentOS 7 server.

Apache HTTP  server is most widely used for  maintain web application for different operating systems including UNIX, Linux, MAC  and Windows based.
 
 PHP language is used to general purpose scripting language for especially  web development, web blogs and etc.
 
 MySQL is a most popular database for use in web applications, on the previous posts we described as follows.

 MySQLAdmin Commands
 MySQLcheck Commands
 MySQL Backup and Restore

 MySQL Query Reports
 MySQL Storage Engine

Install Apache Web Server :


As possible to install httpd web server in two ways, one is manually configured Apache modules and another is using yum command,

#  yum install httpd*  -y

Dependencies Resolved
================================================================================================
 Package                        Arch       Version               Repository    Size
================================================================================================
Installing:
 httpd                         x86_64      2.4.6-18.el7.centos    updates      2.7 M
 httpd-devel                   x86_64      2.4.6-18.el7.centos    updates      181 k
 httpd-manual                  noarch      2.4.6-18.el7.centos    updates      1.3 M
 httpd-tools                   x86_64      2.4.6-18.el7.centos    updates      77 k
Installing for dependencies:   
 apr                           x86_64       1.4.8-3.el7           base         103 k
 apr-devel                     x86_64       1.4.8-3.el7           base         188 k
 apr-util                      x86_64       1.5.2-6.el7           base         92 k
 apr-util-devel                x86_64       1.5.2-6.el7           base         76 k
 cyrus-sasl                    x86_64       2.1.26-17.el7         base         87 k
 cyrus-sasl-devel              x86_64       2.1.26-17.el7         base         309 k
 expat-devel                   x86_64       2.1.0-8.el7           base         56 k
 libdb-devel                   x86_64       5.3.21-17.el7_0.1     updates      38 k
 mailcap                       noarch       2.1.41-2.el7          base         31 k
 openldap-devel                x86_64       2.4.39-3.el7          base         796 k

Transaction Summary
================================================================================================
Install  4 Packages (+10 Dependent packages)

Once installed this packages in your system check with whereis command,
 
#  whereis httpd
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/include/httpd /usr/share/httpd /usr/share/man/man8/httpd.8.gz

HTTPD configuration file located in /etc/httpd/httpd.conf

To checks your configuration file,
 
# apachectl configtest    
Syntax OK

To configure httpd service to be automatically started at boot time just enabled it.
 
# systemctl enable httpd.service

To start your HTTPD Service now execuate below command,
 
# systemctl start httpd.service

Also same command to check httpd status, restart and stop the service.
 
# apachectl status  | start | restart | stop

Do you want to check your httpd process status,
 
# ps aux|grep httpd

root      6702  2.2  0.9 209476  4804 ?        Ss   11:56   0:00 /usr/sbin/httpd -DFOREGROUND
apache    6703  0.0  0.5 209476  2832 ?        S    11:56   0:00 /usr/sbin/httpd -DFOREGROUND
apache    6704  0.0  0.5 209476  2832 ?        S    11:56   0:00 /usr/sbin/httpd -DFOREGROUND
apache    6705  0.0  0.5 209476  2832 ?        S    11:56   0:00 /usr/sbin/httpd -DFOREGROUND
apache    6706  0.0  0.5 209476  2832 ?        S    11:56   0:00 /usr/sbin/httpd -DFOREGROUND
apache    6707  0.0  0.5 209476  2832 ?        S    11:56   0:00 /usr/sbin/httpd -DFOREGROUND
root      6709  0.0  0.1 112640   960 pts/0    S+   11:56   0:00 grep --color=auto httpd

To check which network port number is running on httpd service,
 
# netstat -alnp | grep httpd

Install PHP Scripting Language:

Install PHP in your system using YUM command,
 
# yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

Check the PHP installed path,
 
# whereis php

Note :

If the html or php extension not working on browser just add the below line in httpd.conf file
 
# vim /etc/httpd/conf/httpd.conf

AddType text/html .shtml .html .php

LoadModule php5_module        modules/libphp5.so

Do you want to check your PHP moudles configured with 
 
#  php -i

Install MySQL Database:

Install repo file for MySQL, download package using wget command,
 
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

Install repository,
 
# rpm -ivh mysql-community-release-el7-5.noarch.rpm 

Preparing...              ######################## [100%]
Updating / installing...
   1:mysql-community-release-el7-5  ######################### [100%]

To check whether the repository is installed to that specific location,
 
# ls -al /etc/yum.repos.d/ | grep mysql

-rw-r--r--  1 root root 1209 Jan 29  2014 mysql-community.repo
-rw-r--r--  1 root root 1060 Jan 29  2014 mysql-community-source.repo

Install MySQL database using YUM commnad,
 
# yum install mysql-server

# whereis mysql

mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

To configure MySQL service to be automatically started at boot time just enabled it.
 
# systemctl enable mysqld.service

To Start, Stop, Restart and check the Status of  MySQL server,
 
# systemctl start mysqld.service

# systemctl stop mysqld.service


# systemctl status mysqld.service

# systemctl restart mysqld.service

Open the MysQL on terminal,
 
# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)