Friday, June 17, 2011

Apache mod_cache (Ubuntu 10+)

You need to edit the /etc/apache2/mods-available/disk_cache.conf the command will be ---

gedit /etc/apache2/mods-available/disk_cache.conf


Make sure you uncomment the CacheEnable disk / line, so that the minimal configuration looks as follows:
 CacheRoot /var/cache/apache2/mod_disk_cache

# If you enable disk caching, you need to use htcacheclean from the
# apache2-utils package to ensure that the cache does not grow indefinitely.
# See the htcacheclean man page for details.

# There is currently no mechanism in the Debian package to start htcacheclean
# automatically, but it is planned to add such a mechanism in the future.

CacheEnable disk /

CacheDirLevels 5
CacheDirLength 3
</IfModule>

Now we can enable mod_cache and mod_disk_cache:
sudo a2enmod cache
sudo a2enmod disk_cache

To make sure that our cache directory /var/cache/apache2/mod_disk_cache doesn't fill up over time, we have to clean it with the htcacheclean command. That command is part of the apache2-utils package which we install as follows:
sudo apt-get install apache2-utils 

Afterwards, we can start htcacheclean as a daemon like this:

htcacheclean -d30 -n -t -p /var/cache/apache2/mod_disk_cache -l 100M -i

This will clean our cache directory every 30 minutes and make sure that it will not get bigger than 100MB. To learn more about htcacheclean, take a look at
man htcacheclean

Of course, you don't want to start htcacheclean manually each time you reboot the server - therefore we edit /etc/rc.local...
gedit /etc/rc.local

... and add the following line to it, right before the exit 0 line:
[...]
/usr/sbin/htcacheclean -d30 -n -t -p /var/cache/apache2/mod_disk_cache -l 100M -i
[...]

This will start htcacheclean automatically each time you start the server.

Thursday, June 16, 2011

Apache proxy server setup(Ubuntu 10+)

In your apache2 server you have the folder /etc/apache2/sites-available

To edit the default file you should change the file permission
The code will be
sudo chmod 777 /etc/apache2/sites-available/default



You need to add these two lines in the default file and the line should not be in the outside of
<VirtualHost>................</VirtualHost>


ProxyPass        /path  http://www.google.com/
ProxyPassReverse /path http://www.google.com/


after that you should do enable the proxy and proxy_http. The command will be like that

sudo a2enmod proxy
sudo a2enmod proxy_http


Atlast, you should reload the apache server

 sudo /etc/init.d/apache2 reload


The paste the url in the browser :

localhost/path


It will redirect you in google.com site