Friday, 15 May 2015

Dispatcher Configuration on Apache2 Server

Some of my colleagues wants to know the easiest way of dispatcher configuration on Apache2 server so this post is for you guys. In this tutorial, 
I will explain the easiest way to configure dispatcher on Apache2 server.  
For this post, I used the latest version of Apache2, dispatcher & Ubuntu these are -

Apache2 version 2.4.10 (Current 2.4.12)
dispatcher version 4.1.9
OS version is Ubuntu 15.04

Note - This configuration will also work on Ubuntu 14.04.
So Let's start - 
Install Apache2 server on your Ubuntu machine using command -
sudo apt-get install Apache2

Now type the command
sudo service apache2 start

Then hit a url in your web browser  
http://localhost:80 or http://localhost

You will get Apache2 welcome screen.











Download the dispatcher package from Package Share. Location is -
https://www.adobeaemcloud.com/content/companies/public/adobe/dispatcher/dispatcher.html

Extract this *.tar.gz file, You will get a folder named as dispatcher-apache2.4-linux-x86-64-4.1.9. 

In this folder you have a file dispatcher-apache2.4-4.1.9.so file, just rename it to dispatcher.so Now this directory have one directory & three files as shown below -
Copy and paste dispatcher.so  file to /usr/lib/apache2/modules location. as shown below - 
If copy & paste not working then you have two ways.
Change the permission of /usr/lib/apache2/modules directory using command -
sudo chmod 777 -R /usr/lib/apache2/modules
Or you use command prompt - 
sudo cp <dispatcher.so file location> <place where to paste this file>


sudo cp /media/ankur/myDisk/software/dispatcher-apache2.4-linux-x86-64-4.1.9/dispatcher.so /usr/lib/apache2/modules/ 

In dispatcher-apache2.4-4.1.9 directory there is another directory named as conf. In conf directory there is a file named as dispatcher.any

Just copy this file and paste in /etc/apache2/conf-available directory. as shown below - 
Again if you are not able to paste this file directly then, you can either change the permission of Apache2 directory or use command line to copy and paste this file. 
I am changing the permission of Apache2 directory using command 
sudo chmod 777 -R /etc/apache2 

Now you can easily paste your file in conf-available directory as well as in other directories of apache2 folder.

Now create a soft link in conf-enabled directory using command 
ln -s /etc/apache2/conf-available/dispatcher.any /etc/apache2/conf-enabled/dispatcher.any
It will look like - 
At this point if you want to start your Apache2 server you will get a error & server will not be started because you have created a soft link but it is not defined for Apache2. So not to worry about that error we will resolve that shortly.


Now create a file named as dispatcher.load in mods-available folder & write this line-
LoadModule dispatcher_module /usr/lib/apache2/modules/dispatcher.so
It will look like this - 




















Note : - This file will be used to load dispatcher module in Apache2 server.

Create a soft link in mods-enabled directory using this command - 
ln -s /etc/apache2/mods-available/dispatcher.load /etc/apache2/mods-enabled/dispatcher.load
It will look like this - 





















NOTE: - "Sorry for this, but last two images in my blogs are wrong file names are dispatcher.so as displayed in the last two images,  these names are incorrect, filenames must be dispatcher.load in both of these images."

Next step is just open apache2.conf file, search for <Directory> tag here you have to 
add one more <directory> tag as displayed below - 

<Directory />
  <IfModule disp_apache2.c>
          SetHandler dispatcher-handler
  </IfModule>
  Options FollowSymLinks
  AllowOverride None
</Directory>

Now open ports.conf file & at the end of the file add the line - 

<IfModule disp_apache2.c>
     DispatcherConfig conf-enabled/dispatcher.any
     DispatcherLog    logs/dispatcher.log
     DispatcherLogLevel 3
     DispatcherNoServerHeader 0
     DispatcherDeclineRoot 0
     DispatcherUseProcessedURL 0
     DispatcherPassError 0
</IfModule>

Now all set for dispatcher configuration to test your settings first restart the Apache server using command - 
sudo service apache2 start

Now dispatcher configuration with Apache2 is done here is final step -

Go to /etc directory & open hosts file. using command-
sudo gedit /etc/hosts

then add one more line as 
127.0.0.1       publish.versatileankur.com

All set restart your Apache server using
sudo service apache2 restart

Go to your web browser & hit a url publish.versatileankur.com you will get a Apache2 welcome screen.
Note:-
"One more thing is that in dispatcher.any file change the port number to 4503 as default port is 8080."
It starts successfully.

If you need my help then feel free. I have added multiple images in this post. These images are was not required, but it's human behaviour that we can learn early with pictures & movies rather then hard line. So to make this post easy to understand, I tried my level best.



Happy Coding
Namah Shivay