1:-APACHE Installation

 APACHE Version – httpd-2.4.33

Follow the below steps to install apache in CentOS 7

  • Install EPEL Repository

In order to install EPEL repository execute following command:

sudo yum install epel-release -y

  • Install required tools for compilation

sudo yum install autoconf expat-devel libtool libnghttp2-devel pcre-devel -y

  • Download and unpack source code

Here are the links to the packages:

Apache httpd –








  • Unpack

tar -zxvf 2.4.33.tar.gz

tar -zxvf 1.6.3.tar.gz

tar -zxvf 1.6.1.tar.gz


  • APR and APR-Util

Apache requires APR library for compilation. You need to copy the source codes to correct directory:

cp -r apr-1.6.3 httpd-2.4.33/srclib/apr

cp -r apr-util-1.6.1 httpd-2.4.33/srclib/apr-util

It’s important to not to include version number in APR directories. If you just copy apr-1.6.3 without changing the name, it will give you a warning about missing apr directory.


  • Compile source code


 # cd httpd-2.4.33

# ./buildconf

# ./configure –enable-so

# make

  • Install HTTPD

sudo make install

  • Add Apache executables to PATH

If you try to type httpd -v in your command line, it will result in command not found. That’s because httpd is not on your $PATH. I’d like to have all executables from Apache available from everywhere. In order to achieve that, create file

sudo vi /etc/profile.d/

and paste there following contents:

pathmunge /usr/local/apache2/bin

Save the file, log out and log in from your current session to reload your profile. After that you should be able to use httpd -v command:)

  • Add Systemd entry

Starting, restarting, and enabling Apache on server start via systemctl command is very important thing. You need to create another file:

sudo vi /etc/systemd/system/httpd.service

and paste there following contents:



Description=The Apache HTTP Server




ExecStart=/usr/local/apache2/bin/apachectl -k start

ExecReload=/usr/local/apache2/bin/apachectl -k graceful

ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop






  • Save the file and reload the systemctl daemon

sudo systemctl daemon-reload

Now you can try to start your Apache httpd server with following command:

sudo systemctl start httpd


  • Create dedicated user and group for Apache

sudo groupadd www

sudo useradd httpd -g www –no-create-home –shell /sbin/nologin

  • Edit the httpd.conf file and update the user ad group.


User httpd

Group www


Now restart the server service httpd restart

So that’s it. You have fully working Apache httpd in latest version installed on your system .

This process might take some time, but you will have full control over httpd.



2:-MYSQL Installation


Compile and Install Mysql 5.7.18 Configuration and Details


  1. Main features of MySQL 5.7

(1) Native Support Systemd

(2) Better performance: for multi-core CPU, solid-state hard disk, lock has better optimization

(3) Better InnoDB storage engine

(4) More robust replication: replication brings a solution that data is not lost at all. Traditional financial customers can also use mysql database.

(5) Added sys Library: This will be the most frequently accessed library by DBA in the future

(6.) Better optimizer: The significance of optimizer code refactoring will bring tremendous improvements in this and future versions. Oracle is officially addressing the biggest problem before mysql, native JSON type support (JavaScript object Notation)

Note: JSON (JavaScript Object Notation) is a lightweight data exchange format. JSON uses language-independent text formats, but also uses habits similar to the C language family (including c, c++, c#, java, JavaScript, Perl, Python, etc.). These features make JSON an ideal data exchange language. Easy to read and write, but also easy to machine parse and generation (generally used to improve network transmission rate).

Data in key-value pairs

Data is separated by commas

Curly brackets save objects

Square brackets save data


Installation of MySQL 5.7.18


  1. System environment: centos7.2 x86_64

[root@kang ~]# uname -r


[root@kang ~]# cat  /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

Because CentOS 7.2 installs mariadb-libs by default, all must be uninstalled first, if not uninstalled, the installation will be wrong.

Also avoid unnecessary files that have been generated by installing mariadb-libs.

First check to see if mariadb-libs are installed


[root@kang ~]# rpm  -qa | grep  mariadb-libs


Uninstall mariadb-libs

[root@kang ~]# rpm  -e  mariadb-libs –nodeps


  1. Install mysql-related dependency packages

The role of dependency packages:

  • CMake: Since the conventional configure compilation method has been abandoned since version 5.5 of mysql, a CMake compiler is needed to set the compilation parameters of mysql. Such as: installation directory, data storage directory, character encoding, sorting rules, etc.
  • Boost: Starting with mysql 5.7.5, boost libraries are necessary. c++ boost libraries are used in mysql source code, requiring boost 1.59.0 or more to be installed.
  • GCC : is a C language compiling tool under Linux. The source code of mysql is compiled entirely by C and c++. It is required to install GCC.
  • Bison: C/C++ Parser under Linux
  • ncurses: Character Terminal Processing Library


Installation file preparation:

Download cmake-3.5.2.tar.gz.


Download ncurses-5.9.tar.gz.


Download bison-3.0.4.tar.gz.


Download mysql-5.7.18.tar.gz


Download Boost_1_59_0.tar.gz




  • Install required tools for compilation

yum install gcc-c++


(1) Install cmake

[root@kang ~]# tar -zxvf  cmake-3.5.2.tar.gz

[root@kang ~]# cd cmake-3.5.2/

[root@kang cmake-3.5.2]# ./bootstrap

[root@kang cmake-3.5.2]# gmake && gmake install

cmake  -version                     #View cmake version information


(2) Install ncurses

[root@kang ~]# tar -zxvf ncurses-5.9.tar.gz

[root@kang ~]# cd ncurses-5.9/

[root@kang ncurses-5.9]# ./configure && make && make install


(3) Installation of bison

[root@kang ~]# tar -zxvf bison-3.0.4.tar.gz

[root@kang ~]# cd  bison-3.0.4/

[root@kang bison-3.0.4]# ./configure && make && make install


(4) Install boost

[root@kang ~]# tar zxf boost_1_59_0.tar.gz

[root@kang ~]# mv boost_1_59_0 /usr/local/boost


(5) Create mysql users and groups and related directories

[root@kang ~]# groupadd  -r mysql && useradd -r -g mysql -s /bin/false -M mysql

[root@kang ~]# mkdir /usr/local/mysql

[root@kang ~]# mkdir /usr/local/mysql/data


(6.) Compile and install mysql

Decompress the source code package:

[root@kang ~]# tar -zxvf mysql-5.7.18.tar.gz

[root@kang ~]# cd mysql-5.7.18/

[root@kang mysql-5.7.18]#

Execute the cmake command to configure before compilation:


Start compiling and installing:

[root@kang mysql-5.7.18]# make && make install


Note: Detailed configuration parameters:

– Root directory of DCMAKE_INSTALL_PREFIX=/usr/local/mysql#mysql installation

– DMYSQL_DATADIR=/usr/local/mysql/data#mysql database file storage directory

– The directory where the DSYSCONFDIR=/etc#mysql configuration file is located




– DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock# Specifies the location of mysql.sock

– DWITH_PARTITION_STORAGE_ENGINE=1# Installation Support Database Partition

– DEXTRA_CHARSETS=all # Make mysql support all extended characters

– DDEFAULT_CHARSET=utf8 # Sets the default character set of mysql to utf8

– DDEFAULT_COLLATION=utf8_general_ci Sets default character set proofreading rules

– DWITH-SYSTEMD=1 # You can use system D to control mysql services

– DWITH_BOOST=/usr/local/boost # points to the directory where the boost library is located


(7) Setting environmental variables

[root@kang ~]# echo “export PATH=$PATH:/usr/local/mysql/bin” >> /etc/profile

[root@kang ~]# source /etc/profile


(8) Set relevant permissions for mysql data directory files

[root@kang ~]# chown  -R  mysql:mysql  /usr/local/mysql/

[root@kang ~]# cd /usr/local/mysql/

[root@kang mysql]# chmod  755  data/


(9.) Initialize mysql database

[root@kang mysql]# cd /usr/local/mysql/

[root@kang mysql]# mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

Note down the password

(10) Create and modify mysql master configuration file

[root@kang ~]# cd /usr/local/mysql/

[root@kang mysql]# vi /etc/my.cnf












Note: Rescan system D to scan new or changed units

[root@kang mysql]# systemctl daemon-reload


(11.) Configure mysql autostart

[root@kang mysql]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service  /usr/lib/systemd/system

mysql database service failed to start!


[root@kang mysql]# systemctl  start mysqld

Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.

View the error log file:

Through the above error discovery, in mysqld.service, the default pid file is assigned to / var/run/mysqld / directory, but the directory is not established beforehand, so it is necessary to establish the directory manually and assign permissions to mysql users, so that there will be no misreporting!!


[root@kang ~]# mkdir /var/run/mysqld

[root@kang ~]# chown  -R  mysql:mysql /var/run/mysqld/

#systemctl  daemon-reload

Start the mysql service again:  #systemctl  start mysqld

Check the status of mysqld servic: #systemctl status mysqld

View the port number: # netstat -tulpn | grep mysqld

Access mysql database:

mysql -uroot -p YGyr8jr=?,Ta       #Get the temporary password and go to the data directory to view cat mysqld.err | grep password in this way


(12) Setting the password of database administrator user root

[root@kang ~]# mysqladmin  -uroot -p password ‘pwd123’

Enter password:


Here you are, mysql-5.7.18 database is installed at this point!! _____________

Hope to help you!!

Installation process is a bit long to wait patiently!!


3:-PHP Installation

PHP 5.4.16

  • Install PHP

(1) Obtain the PHP source code: php-5.4.16.tar.gz



(2) Decompress source files:

#tar -zvxf php-5.4.16.tar.gz


(3) Install libxm12 and libxml2-devel, otherwise it will appear when compiling the source code.Configure: error: xml2-config not found. Please check your libxml2 installation.”problem.

#yum install libxml2

 #yum install libxml2-devel


(4) Compile the source code:

#cd /usr/local/php-5.4.16

#./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs



(5) Installation

#make install


  • Configure PHP


(1) Copy the php.ini-development file from the PHP source package (/usr/local/php-5.4.16) to /usr/local/lib/ and rename it to Php.ini.

#cp /usr/local/php-5.4.16/php.ini-development /usr/local/lib/php.ini


(2) Modify the Apache configuration file (gedit /usr/local/apache2/conf/httpd.conf) to support parsing of PHP. If httpd.conf does not have the following statements, add them to the LoadModule and AddType items respectively.

      # vi /usr/local/apache2/conf/httpd.conf

LoadModule php5_module modules/

AddType application/x-httpd-php .php


Add index.php after the DirectoryIndex index.html index.html.var line, which means:

DirectoryIndex index.html index.html.var index.php

Restart the Apache server:

#/usr/local/apache2/bin/apachectl restart


(3) Test PHP:

Create a new PHP file test.php in the Apache server’s file root directory (/usr/local/apache2/htdocs/) and enter the following:

# vi /usr/local/apache2/htdocs/test.php






Enter in the browser http://localhost/test.php If you see the image below, it means that PHP has been successfully installed.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.