Month: June 2012

  • [Fixed] Name or service not known: mod_unique_id: unable to find IPv4 address of

    After completing a new cPanel / Plesk / Apache web server setup I observed that Apache web service is not running. On trying to restart the http service, it failed with Apache http error logs as below:

    "[alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "server.example.com"
    Configuration Failed"

    Initially, I suspected that it might an issue with the Apache configuration. Therefore I verified the syntax of the Apache http config file using below command:

    /etc/init.d/httpd configtest

    Unfortunately, there were no issues with the Apache http configuration file.

    After verifying couple of things, I casually checked the /etc/hosts file and noticed that entries of localhost and server hostname were not correct. I made necessary corrections in that file which looked as below.

    127.0.0.1       localhost
    192.168.1.101   WEBSERVER

    Note: Please input your server hostname instead of WEBSERVER as shown in above example.

    Post making changes the Apache web service started without any error and not warning messages were observed in the log.

     If any feedback, queries are always welcome!

  • Modsecurity rule execution error - PCRE limits exceeded

    If you are getting following mod_security error in the Apache error logs

    [Mon Jun 11 16:54:50 2011] [error] [client 171.235.170.226] ModSecurity: Rule 8269d10 [id "-"][file "/usr/local/apache/conf/modsec2.user.conf"][line "763"] - Execution error - PCRE limits exceeded (-8): (null). [hostname "www.example.com"] [uri "/wp-content/themes/daily/timthumb.php"] [unique_id "T9YUytXlXKcADxXq-WUAAAAg"]

    then to get rid of the error you will have to make some server side changes as the above rule can not be excluded for single domain on the server.

    1) Login to the server as a root user from shell.

    2) Go to Apache configuration directory

    cd /usr/local/apache/conf

    3) Create a new file

    touch pcre_modsecurity_exceeded_limits.conf

    4) Add the following contents by editing the above file using any editor like vi

    SecPcreMatchLimit 150000
    SecPcreMatchLimitRecursion 150000

    5) Change the permission of the file to 600

    chmod 600 /usr/local/apache/conf/pcre_modsecurity_exceeded_limits.conf

    6) Open the mod_security file containing rules

    vi /usr/local/apache/conf/modsec2.user.conf

    7) Locate the line

    <IfModule mod_security2.c>

    8 ) Add the below line above the line located at step 7 and save the file.

    Include "/usr/local/apache/conf/pcre_modsecurity_exceeded_limits.conf"

    9) Make a configuration test before restarting Apache service

    /etc/init.d/httpd configtest

    10) If there is no syntax then restart Apache service

     If any feedback, queries are always welcome!

    Review Overview

    User Rating: Be the first one !
  • [Solved] Error: no immediate delivery: more than 10 messages received in one connection

    exim logoIf you are receiving below error message in the exim log

    "Error: no immediate delivery: more than 10 messages received in one connection"

    then you will have to edit the exim configuration file and make some changes.

    1) Login to the server via shell as a root user

    2) Edit the exim configuration file using any favorite editor

    vi /etc/exim.conf

    3) Search for "smtp_accept_queue_per_connection" , if not preset then add the line

    smtp_accept_queue_per_connection=30

    Read More »

  • How To Clear Cache / Buffer memory & set cron job on Linux

    The cache / buffer memory in Linux is nothing but a set of cache stored on the server which contains frequently visited pages. The cache configuration is done in a such a way that whenever any data is requested by RAM it will check the cache memory and serve the data from cache memory if available. This helps to increase the response time and optimum usage of the server resources.

    cache memory

    The cache / buffer memory from RAM on Linux and Unix servers can be flushed in different ways.

    How to clear cache / buffer memory on a Linux server?

    Option 1:

    To clear pagecache, dentries & inodes i.e. flush all from cache memory

    sync; echo 3 > /proc/sys/vm/drop_caches

    Option 2:

    To clear only inodes and dentries from cache memory

    sync; echo 2 > /proc/sys/vm/drop_caches

    Option 3:

    To clear only page cache from cache memory

    sync; echo 1 > /proc/sys/vm/drop_caches

    How to set a cron job to clear cache memory in Linux?

    The cache memory may be required to cleaned up at regular intervals and free up the disk space. The same can be achieved by creating a cronjob to automatically clear the cache memory using crontab.

    Step 1:

    • Access the desired server through shell as a root or sudo user.

    Step 2:

    • Create a shell script say "clearcache.sh" under root  (/root) partition with following commands
    #!/bin/sh
    sync; echo 3 > /proc/sys/vm/drop_caches

    Step 3:

    • Set the permission of "clearcache.sh" script to 755
    chmod 755 /root/clearcache.sh

    Step 4:

    • Edit the system crontab file using below command
    crontab -e

    Step 5:

    • Enter the following line in crontab file to set cron job for clearing cache memory automatically
    0 * * * * /root/clearcache.sh

    The above cron job will execute the "clearcache.sh" script every hour of first second.

    Step 6:

    • Restart cron service
    /etc/init.d/crond restart

    Note: One should be a root user or sudo user to perform the above mentioned operations.

    Should I clear / flush cache memory from RAM at regular intervals?

    Well it depends upon the situation. On production servers it is not advisable to clear cache at regular since this will force server to serve pages from disk instead of cache till cache is not getting build up thus increasing server load and resources.

    To learn more about cache, visit the LinuxAteMyRAM website. Hopefully, after referring to the website the concept about cache in Linux should get clear.

    Please let us your feedback, queries by posting in comment section.

    Review Overview

    User Rating: 4.9 ( 1 votes)
  • [How To] Disable mod security on a Linux Server

    Here is a quick guide about mod_security and how to disable mod_security in various scenarios.
    Please note that you will require shell access with root user to perform the below steps.

    The mod_security has two versions and rules for each of them are different. Hence, before adding rule one should be sure about mod_security version.

    How to find mod_security version?

    The mod_security version can be found out by checking at location

    /usr/local/apache/conf/mod*

    where

    mod_security.c = mod_security version 1
    mod_security2.c = mod_security version 2

    Various ways to disable mod_security

    Create the files as mentioned below:
    For mod_security 1

    /usr/local/apache/conf/userdata/std/1/username/websitename/allow.conf

    and

    For mod_security 2

    /usr/local/apache/conf/userdata/std/2/username/websitename/allow.conf

    Include the above file path in virutalhost entry of the domain by updating Apahce configuration file

    Include "/usr/local/apache/conf/userdata/std/1/username/websitename/*.conf"

    or

     Include "/usr/local/apache/conf/userdata/std/2/username/websitename/allow.conf"

    Add the following rules depending on the scenarios in the allow.conf file to take effect and restart Apache service.

    Scenarios:

    To disable mod_security 1 for complete domain

    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>

    To disable mod_security 2 for complete domain

    <IfModule mod_security2.c>
    SecRuleEngine Off
    </IfModule>

    To exclude single mod_security 1 rule for a specific link

    If Apache error log shows

    [Mon Oct 12 16:11:20 2009] [error] [client 121.15.245.215] ModSecurity: Access denied with code 400 (phase 2). Pattern match “^\\w+:/” at REQUEST_URI_RAW. [file "/usr/local/apache/conf/modsec.user.conf"] [line "26"] [id "960014"] [msg "Proxy access attempt"] [severity "CRITICAL"] [tag "PROTOCOL_VIOLATION/PROXY_ACCESS"] [hostname "www.domain.com"] [uri "/index.php"] [unique_id "StNHGF5MxosAACUwIYQAAAAD"]
    <IfModule mod_security.c>
    <Location "/index.php">
    SecFilterRemove 960014
    </Location>
    </IfModule>

    To exclude single mod_security 2 rule for a specific link

    <IfModule mod_security2.c>
    <LocationMatch “/index.php“>
    SecRuleRemoveById 960014
    </LocationMatch>
    </IfModule>

    To exclude mod_security 1 for specific link or complete folder

    <LocationMatch /admin.php>
    <IfModule mod_security.c>
    SecFilterEngine Off
    </IfModule>
    </LocationMatch>
    
    <LocationMatch /wp-admin/>
    <IfModule mod_security.c>
    SecFilterEngine Off
    </IfModule>
    </LocationMatch>

    To exclude mod_security 2 for specific link or complete folder

    <LocationMatch /admin.php>
    <IfModule mod_security2.c>
    SecRuleEngine Off
    </IfModule>
    </LocationMatch>
    
    <LocationMatch /wp-admin/>
    <IfModule mod_security2.c>
    SecRuleEngine Off
    </IfModule>
    </LocationMatch>

    Important: Always do Apache configuration test before restarting Apache service.
     If any feedback, queries are always welcome!

    Review Overview

    User Rating: 0.5 ( 1 votes)
  • Unable to include potential exec [ Fixed ]

    apache logo

    The Apache version 2.2.3 will not allow to include executable by default because "Options -IncludesNoExec" directive is set to secure  the web server.
    The CGI includes can be enable by editing .htaccess under your account and updating with the following line.

    Options +Includes +ExecCGI

     

    If any feedback, queries are always welcome!

Back to top button