How to install Apache Thrift on Ubuntu 14.04

1. Introduction

Apache Thrift is just a software framework written in C++. It was initially developed in 2007 by Facebook but now it is an Open Source project in Apache Software Foundation (ASF). The RPC is Remote Procedure Call is a type of protocol, requesting a service from one server to another server in a network using programs. Tt does not need any kind of network details for the whole process. In this article, We are going to install Apache Thrift.

Install all the dependencies

# apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev ant

2. Install Java JDK

Check whether the Java JDK package is installed or not. You may use the below command to verify :

# java --version

If the Java JDK is not installed. Please the command to install Java JDK :

# apt-get install openjdk-7-jre 
# apt-get install openjdk-7-jdk

Thus we have completed installing the dependencies.

3. Installation

Download the latest version of Apache Thrift from there official site in to your local directory :


Extract the tar file :

# tar -xvf thrift-0.9.3.tar.gz

Now install thirift folder :

# cd thrift-0.9.3/
# ./configure
thrift 0.9.3

Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : yes
Building C# Library .......... : no
Building Python Library ...... : no
Building Ruby Library ........ : no
Building Haxe Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no
Building D Library ........... : no
Building NodeJS Library ...... : no
Building Lua Library ......... : no

C++ Library:
   Build TZlibTransport ...... : yes
   Build TNonblockingServer .. : yes
   Build TQTcpServer (Qt4) .... : no
   Build TQTcpServer (Qt5) .... : no

Java Library:
   Using javac ............... : javac
   Using java ................ : java
   Using ant ................. : /usr/bin/ant

# make 
# make install

Thus the installation process is completed. We can verify the installation using the command below :

# thrift -version
Thrift version 0.9.3

4. Conclusion

Thus we have completed the installation of Apache Thrift.

How to install Nginx as Reverse Proxy in front of Apache on Ubuntu 15.10

1.0 Introduction

Nginx or “engine-x” is a high-performance web server with low memory usage, created by Igor Sysoev in 2002. Nginx is not just a web server, it can be used as a reverse proxy for many protocols like HTTP, HTTPS, POP3, SMTP, and IMAP and as a load balancer and HTTP cache as well.

In this tutorial, I will install and configure Nginx as a caching reverse proxy for an Apache web server on Ubuntu 15.10, Nginx is used as the front end and Apache as the back end. Nginx will run on port 80 to respond to requests from a user/browser, the request will then be forwarded to the apache server that is running on port 8080.

2.0 Install Apache and PHP

Log in to your ubuntu server as a root user.

Before install the package you have to update the apt cache using “apt-get”

#apt-get update

Then install apache with the apt-get command.

# apt-get install apache2

Once apache is installed, we must install PHP.

# apt-get install php5 php5-mysql libapache2-mod-php5

3.0 Configure Apache and PHP

By default, apache listens on port 80. We have to configure apache to run on port 8080 for our proxy setup as port 80 will be used by nginx later. We have to edit the apache configuration file “/etc/apache2/ports.conf”. And then proceed with the virtual host configuration in the “/etc/apache2/sites-available/” directory.

First change the port for apache to 8080 by editing the file “ports.conf” with the vim editor.

#vim /etc/apache2/ports.conf

On line 5, change port 80 to 8080 as follows.

Listen 8080

Now go to the virtualhost directory and edit the file “000-default.conf”.

   #cd sites-available/
   #vim 000-default.conf

Make sure your configuration is same as below



    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Test the configuration and restart apache

  #apachectl configtest
  #systemctl restart apache2

Create a new file with the name “info.php” in the directory “/var/www/html/” with the following content

  #cd /var/www/html/
  #echo "" > info.php

Visit your site in browser


4.0 Install Nginx

Install Nginx with the following apt-get command

#apt-get install nginx

5.0 Configure Nginx

Once Nginx is installed, configure Nginx to act as reverse proxy for the apache web server that running on port 8080.
Go to the nginx configuration directory and edit the file “nginx.conf”.

  #cd /etc/nginx/
  #vim nginx.conf

Enable Gzip compression for Nginx by uncomment the gzip lines.

        # Gzip Settings
       gzip on;
        gzip_disable "msie6";
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

The most important is :

  • gzip on : to turn gzip compression.
  • gzip_types : is list of MIME-types which you want to turn the compression.
  • gzip_proxied any : is enable compression for proxied request.

Right under gzip settings, add these proxy cache settings:

 # Proxy Cache Settings
 proxy_cache_path /var/cache levels=1:2 keys_zone=reverse_cache:60m inactive=90m max_size=1000m;

Now we will configure a virtualhost in the directory “/etc/nginx/sites-available”

New virtualhost configuration file named “reverse.conf”.

   #cd /etc/nginx/sites-available
   #vim reverse.conf

Paste the configuration below:

   server {
    listen 80;

    # Site Directory same in the apache virtualhost configuration
    root /var/www/html; 
    index index.php index.html index.htm;

    # Domain

    location / {
        try_files $uri $uri/ /index.php;

    # Reverse Proxy and Proxy Cache Configuration
    location ~ \.php$ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

        # Cache configuration
        proxy_cache reverse_cache;
        proxy_cache_valid 3s;
        proxy_no_cache $cookie_PHPSESSID;
        proxy_cache_bypass $cookie_PHPSESSID;
        proxy_cache_key "$scheme$host$request_uri";
        add_header X-Cache $upstream_cache_status;

    # Enable Cache the file 30 days
    location ~* .(jpg|png|gif|jpeg|css|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
        proxy_cache_valid 200 120m;
        expires 30d;
        proxy_cache reverse_cache;
        access_log off;

    # Disable Cache for the file type html, json
    location ~* .(?:manifest|appcache|html?|xml|json)$ {
        expires -1;

    location ~ /\.ht {
        deny all;

Take backup the “default” configuration file from “/etc/nginx/sites-available” directory.

  #mv default default.bak

Then activate the new virtualhost configuration.

#ln -s /etc/nginx/sites-available/reverse.conf /etc/nginx/sites-enabled/

Test the nginx configuration and restart nginx.

  #nginx -t
  #systemctl restart nginx

6.0 Configure Logging

In this step, I will configure apache to log the real ip of the visitor instead of the local IP. Install the apache module “libapache2-mod-rpaf” and edit the module configuration file.

   #apt-get install libapache2-mod-rpaf
   #cd /etc/apache2/mods-available/
   #vim rpaf.conf

Add the server IP to the line 10.

  RPAFproxy_ips ::1

Restart apache

   #systemctl restart apache2

Test rpaf by viewing the apache access log with the tail command

#tail -f /var/log/apache2/access.log

How to install and configure LAMP ( Linux, Apache, MySQL and PHP ) in Ubuntu 14.04

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

An ordinary server with Ubuntu 14.04 LTS installed. You can install it on any platform, but here the documentations are based on the Ubuntu / debian server.

3. Installation

Please proceed with the following steps:

3.1 Apache2 Installation

Type the below command for installing apache 2 package from repository.

#  apt-get install apache2

Restart apache service

# /etc/init.d/apache2 restart

Apache will start working with minimal configuration. Now Open your server-ip in the browser and You can see the apache ubuntu test page.( Default document root is located in this path /var/www/html )

apache3 ubuntu default

3.2 MySQL installation

Issue the below command to install mysql server with dependencies.

# apt-get install mysql-server

During installation it will prompt for a new password for mysql root . Give some strong password and retype the same password for confirmation.

After installation check the Database connection.

Check the service status.

# /etc/init.d/mysql status

Service is already up , Now Type this command to login

# mysql -u root -p

Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 42
Server version: 5.5.35-1ubuntu1 (Ubuntu)
Copyright (c) 2000, 2013, 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
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

Mysql server installation is over.

3.3 PHP installation

Type the below command to install php5.

# apt-get install php5 php5-mysql

Create a php file and paste the below code into the file to show the php configuration . Goto the default apache root path /var/www/html . create a new file info.php and paste the below code and save it.

# vi /var/www/html/info.php

Please use the following codes to create a phpinfo page.


Now restart the apache2 service.

# /etc/init.d/apache2 restart

Now open the file in the browser ( Eg: http://yourip/info.php ) you can see the php information page as below.
Make sure you can see the mysql details in the php information page.

ubuntu phpinfo

We have successfully configured Apache2 , mysql and php.

How to install and configure Linux, Apache, Mariadb and PHP (LAMP ) on Centos7 or RHEL7

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

You may need an operating system RHEL 7 or Centos 7 in your dedicated or vps server. Please make sure to set a hostname for your server and its dns is pointing to the IP address of the server.

3. Installation

Please proceed with the following step by step procedures:

3.1 Install Apache

Apache2 is directly available as a CentOS 7.0 package, therefore we can install it like this:

# yum -y install httpd

Now configure your system to start Apache at boot time.

# systemctl start httpd.service
# systemctl enable httpd.service

Now direct your browser to http://your-IP, and you should see the Apache2 place holder page:


3.2 Install MariaDB

To install MySQL, we do install mariadb like this:

# yum -y install mariadb-server mariadb

Then we create the system startup links for MySQL (So that MySQL starts automatically whenever the system boots) and start the MySQL server:

# systemctl start mariadb.service
# systemctl enable mariadb.service

Set passwords for the MySQL root account:

# mysql_secure_installation

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.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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] <--ENTER
 ... 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] <--ENTER
 ... Success!

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.

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

Reload privilege tables now? [Y/n] <--ENTER
 ... Success!

Cleaning up...

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

3.3 Install PHP

We can install PHP5 and the Apache PHP5 module as follows:

# yum -y install php php-mysql

We must restart Apache afterwards:

# systemctl restart httpd.service

Testing PHP5 / Getting Details About Your PHP5 Installation

# vi /var/www/html/info.php

Now add the following phpinfo code content in this file.


Now we call that file in a browser (e.g. http://Your IP/info.php):


You may need We have successfully configured Apache2 , mysql and php.

How to install and configure Linux,Apache,Mysql(Mariadb) and PHP (a.k.a LAMP) in Centos 7 / RHEL7


LAMP (Linux, Apache, Mysql & PHP ) is an open source web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. It is powerful and also comparatively simple and easy to use. This article will help you configure LAMP in Centos7.


Operating System: Centos 7 or RHEL 7

Before you begin LAMP INSTALLATION , you should have a server with root user privilege. By completing steps mentioned below you can configure LAMP in your server.

3. Install Apache

We can install Apache easily using CentOS’s package manager, yum.

# yum install httpd

Afterwards, your web server is installed , you can start Apache on your sever:

# systemctl start httpd.service

Now you can check webserver by using server IP address in your browser:

http://your_server_IP_address/    >>>>> here it is

Now you can see the default CentOS 7 Apache web page. Please see some sample screen shorts below,


4. Install MySQL (MariaDB)

MariaDB is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source.

# yum install mariadb-server mariadb

When the installation is complete, we need to start MariaDB with the following command:

# systemctl start mariadb

Now your mysql database is running.You can access database without any password its not secure so we need to provide password protection.

# mysql_secure_installation

The prompt will ask you for your current root password. Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter. Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions:

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

After this when you try to access database with out password it may show an error like this:

[root@arunima-centos7 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

You set a mysql root password for your database server so from now on you can’t access it without password.

“root” session do not know password to mysql root user.

If you want to make easier to access your mysql create a .my.cnf in /root/ and add the following content

# touch /root/.my.cnf
# vim /root/.my.cnf

user = root
password = mysqlrootpassword

where of-course “mysqlrootpassword” is your password for mysql’s root user so when you execute mysql command it uses this password.

Install PHP

PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information, and hand the processed content over to our web server to display.

# yum install php php-common php-gd php-mysql

After installing PHP, you should restart apache.

# systemctl restart httpd.service

In order to test that our system is configured properly for PHP, we can create a very basic PHP script.

We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the “web root” or “document root”.

In CentOS 7, this directory is located at /var/www/html/. We can create the file at that location as shown below:


Now we can test whether our web server can correctly display content generated by a PHP script.


Please see a sample screen short of phpinfo below,


Symlink / Softlink Protection For Security In Apache – SOLVED

You may need to read the whole article before choosing it.

Step 1 :  You may need to  turn on “SymLinksIfOwnerMatch” in WHM Apache Global Configuration

Step  2:  Apply the Patch from rack9 , what he do is to turn on by default in apache  source and compile it to apply this patch please do it as follows,

wget -O /scripts/before_apache_make
chmod 700 /scripts/before_apache_make

#Rebuild apache after.


Step  3 :  Apply the Symlink Race condition patch from Blue Host. It is is now available in easy apache. To apply the patch, select Symlink Race Condition Protection from the Exhaustive Options list during the EasyApache build process.

Please read the whole article from

Now check the server if it is already have a Symlink

# find /home*/*/public_html -type l

All the above solutions can be exploited  easily too. Our Security team tested and find out it. But there is another  good option in cloud linux.

This issue can easily be fixed in Cloud linux Using the secure links. It is one of the best solution.  It use  a kernel level protection. You can enable it in sysctl.conf  by adding the following lines

fs.enforce_symlinksifowner = 1

You can set any of the followivg values

fs.enforce_symlinkowner == 0 -> do not check symlink ownership
fs.enforce_symlinkowner == 1 -> deny if gid == symlinkown_gid
fs.enforce_symlinkowner == 2 -> deny if gid > symlinkown_gid   [since kernel 2.6.32-379.19.1.lve1.2.8]

If you need to exclude Symlink check of a specific user , you can do it as follows,

fs.symlinkown_gid = XX   , where XX is the  UID

To apply the Sysctl changes , plese do it as follows,

sysctl -p

Please read more about it from

Replacing mod_rpaf with mod_remoteip in apache 2.4 Nginx Real_IP Problem Solution

Now apache 2.4 provide areal remoteIP software . It there will be enabled by default . You can check it as follows,

# httpd -l | grep mod_remoteip.c

If you get the above results that means the remoteip module already compiled and enable in apache. otherwise you can download it from

And compile it as follows,

# apxs -cia mod_remoteip.c

You may now need to add the following lines to httpd.conf  for enabling this  REMOTE_ADDR with real visitor Ip as follows,

Add the following lines to httpd.conf

#LoadModule remoteip_module /usr/lib/apache/    # This line only need if you compile this module alone
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy X.X.X.X/24      # Your server IP address

Also please note this module is not available for  lower versions of apache like apache 2.2.x , for that you have to use the mod_rpaf module itself .