Installing CSF in OpenVZ Hardware Node

If you install CSF on OpenVZ hardware node, you won’t be able to access VPS. To fix this create a file /etc/csf/csfpre.sh with following content

[root@server12 ~]# cat /etc/csf/csfpre.sh
/sbin/iptables -A INPUT -i venet0 -j ACCEPT
/sbin/iptables -A OUTPUT -o venet0 -j ACCEPT
/sbin/iptables -A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
/sbin/iptables -A FORWARD -j ACCEPT -p all -s 0/0 -o venet0

[root@server12 ~]#

Restart csf, you will be able to access VPS.

csf -r
Posted in OpenVZ | Tagged , , | Leave a comment

eximrm – delete mails in exim queue

Create file /usr/local/bin/eximrm

/usr/local/bin/eximrm

with following content

#!/bin/bash

exim -bpu | awk '{print $3}' | xargs exim -Mrm

chmod 755 the file

chmod 755 /usr/local/bin/eximrm

Now running the command “eximrm” will delete mails in Exim mail queue.

[root@server12 ~]# eximrm
Message 1RORpm-001oWx-SL has been removed
Message 1RORrq-001paP-Ug has been removed
Message 1RORut-001rEc-LY has been removed
Message 1RORvN-001rdN-Gs has been removed
Message 1RORvT-001rem-R9 has been removed
Message 1RORvZ-001rgb-Dc has been removed
Message 1RORvi-001rih-M4 has been removed
Message 1RORw8-001rpr-Lp has been removed
Message 1ROS0o-001uNy-Jl has been removed
Message 1ROS3l-001w1j-Dt has been removed
Message 1ROS3u-001w4P-NV has been removed
Message 1ROS5r-001x5m-4Q has been removed
Message 1ROS67-001x8O-Q6 has been removed
Message 1ROS6T-001xBu-N8 has been removed
Message 1ROS9Q-001zAP-VW has been removed
Message 1ROSA7-001zd3-1Y has been removed
Message 1ROSFa-0022T3-Fl has been removed
Message 1ROSFb-0022TM-Ch has been removed
Message 1ROSJz-0024wf-W1 has been removed
Message 1ROSRU-0029FD-L2 has been removed
Message 1ROSRc-0029IB-JX has been removed
Message 1ROSS2-0029PJ-BC has been removed
Message 1ROSSA-0029Rk-Un has been removed
Message 1ROSTg-002APg-ER has been removed
Message 1ROSU9-002Ap8-Oe has been removed
Message 1ROSVH-002BRX-6x has been removed
Message 1ROSVj-002BZP-2E has been removed
Message 1ROSX8-002CTN-DZ has been removed
[root@server12 ~]# cat  /usr/local/bin/eximrm
#!/bin/bash

exim -bpu | awk '{print $3}' | xargs exim -Mrm

[root@server12 ~]#
Posted in Exim | Tagged , | Leave a comment

PHP Errors to File

To log all PHP Errors to log file, edit php.ini file, add

error_log = /var/log/php-errors.log

To turn off displaying errors to browser, change value of display_errors to Off

display_errors = Off
Posted in PHP | Tagged , | Leave a comment

Password Protect a Folder with .htaccess

To password protect a folder in Apache, create a password file

[root@server12 ~]# htpasswd -c /path/to/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
[root@server12 ~]#

This is create a password with user user “admin”.

This file should be outside Apache document root.

Now create a .htaccess file with following content in the password protected folder.

AuthUserFile /path/to/.htpasswd
AuthName "Members Only"
AuthType Basic
Require valid-user

To access the folder, you will need to login as admin user created above.

Posted in Apache | Tagged , , | Leave a comment

Develop Java Project in ZendStudio

I recently started doing some small java projects. I have installed Eclipse/intelliJ. I prefer Eclipse as it compile program on saving. Since my project contains many independent programs i like this feature.

I am already using ZendStudio 8. This is also eclipse with some Zend plugins installed. So i descided to use Zend for Java coding, so don’t have to run two eclipses.

To install Java Support, go to

ZendStudio > Help > Install New Software

Click Available Sofftware sites link below Add button, enable Eclipse Repository

Zend already have Java development installed, so you may not need to do above steps.

Go to

File > New Project

Check the “Show All Wizzards” check box.

Now you will able to See Java Project.

Posted in PHP | Tagged , , , , | 1 Comment

pre style for wordpress

pre {
    background: url("http://blog.hostonnet.com/files_hon/wp_pre_bg.gif") repeat scroll left top #FFFFFF;
    border: 1px solid #999999;
    color: #000000;
    display: block;
    font-family: "Courier New",Courier,monospace;
    font-size: 13px;
    line-height: 18px;
    margin: 10px 0 20px;
    overflow-x: scroll;
    overflow-y: auto;
    padding: 18px 10px 17px;
    position: relative;
    z-index: 50;
}
Posted in general | Tagged , | Leave a comment

Using host command

host command is used for dns lookup

root@server1 [~]# host -t mx gmail.com
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
root@server1 [~]# host gmail.com
gmail.com has address 74.125.113.18
gmail.com has address 74.125.113.83
gmail.com has address 74.125.113.17
gmail.com has address 74.125.113.19
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
root@server1 [~]#
Posted in DNS | Tagged , , | Leave a comment

Missing Dependency: libjpeg.so.62 is needed by package xulrunner-1.9.2.22-1.el5_7.i386 (updates)

On a cpanel sever, when running yum update, i get following error

xulrunner-1.9.2.22-1.el5_7.i386 from updates has depsolving problems
  --> Missing Dependency: libjpeg.so.62 is needed by package xulrunner-1.9.2.22-1.el5_7.i386 (updates)
ghostscript-8.70-6.el5_7.3.i386 from updates has depsolving problems
  --> Missing Dependency: libjpeg.so.62 is needed by package ghostscript-8.70-6.el5_7.3.i386 (updates)
--> Running transaction check
---> Package ghostscript.i386 0:8.70-6.el5_7.3 set to be updated
--> Processing Dependency: libjpeg.so.62 for package: ghostscript
---> Package kernel-PAE.i686 0:2.6.18-194.26.1.el5 set to be erased
---> Package kernel-PAE-devel.i686 0:2.6.18-194.32.1.el5 set to be erased
---> Package xulrunner.i386 0:1.9.2.22-1.el5_7 set to be updated
--> Processing Dependency: libjpeg.so.62 for package: xulrunner
--> Finished Dependency Resolution
xulrunner-1.9.2.22-1.el5_7.i386 from updates has depsolving problems
  --> Missing Dependency: libjpeg.so.62 is needed by package xulrunner-1.9.2.22-1.el5_7.i386 (updates)
ghostscript-8.70-6.el5_7.3.i386 from updates has depsolving problems
  --> Missing Dependency: libjpeg.so.62 is needed by package ghostscript-8.70-6.el5_7.3.i386 (updates)
Error: Missing Dependency: libjpeg.so.62 is needed by package ghostscript-8.70-6.el5_7.3.i386 (updates)
Error: Missing Dependency: libjpeg.so.62 is needed by package xulrunner-1.9.2.22-1.el5_7.i386 (updates)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

I checked if libjpeg is disabled in /etc/yum.conf

root@server20 [~]# cat /etc/yum.conf | grep jpeg
exclude=apache* bind-chroot courier* dovecot* exim* filesystem httpd* libjpeg* mod_ssl* mysql* nsd* perl* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail*
root@server20 [~]#

I checked another cpanel server, found libjpeg* is not disabled in that server. So i removed libjpeg* from /etc/yum.conf and yum update worked properly.

Posted in CentOS | Tagged , , | Leave a comment

Hide X-Powered-By: PHP

On a web site, HTTP headers show PHP version like X-Powered-By: PHP/5.1.6

[root@server12 ~]#  curl -I http://netfree.netfreehost.com
HTTP/1.1 200 OK
Server: nginx/1.1.0
Date: Sun, 11 Sep 2011 20:00:40 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.1.6
Cache-Control: no-cache, pre-check=0, post-check=0
Expires: 0
Pragma: no-cache
[root@server12 ~]#

To disable PHP version showing in header, edit /etc/php.ini

vi /etc/php.ini

Set expose_php to off

expose_php=Off

Now restart web server.

After restarting, Http headers stopped showing X-Powered-By: PHP/5.1.6

[root@server12 ~]#  curl -I http://netfree.netfreehost.com
HTTP/1.1 200 OK
Server: nginx/1.1.0
Date: Sun, 11 Sep 2011 20:04:41 GMT
Content-Type: text/html
Connection: keep-alive
Cache-Control: no-cache, pre-check=0, post-check=0
Expires: 0
Pragma: no-cache

[root@server12 ~]#
Posted in PHP | Tagged , , , | Leave a comment

Block IP in Windows 2003

1. Start > Run > Type mmc and click run
2. In the console select Add/Remove Snap-in from the File menu and click the Add button in the Standalone tab.
3. In the Add Standalone Snap-in dialog box select IP Security Policy Management and click Add
4. In the Select Computer or Domain dialog box select Local Computer and click Finish.
5. Now just close the Add Standalone Snap-in and Add/Remove Snap-in dialog boxes by clicking the Close and OK buttons respectively.
6. You should now be back to the console. In the left frame right click IP Security Policies on Local Computer and select Create IP Security Policy.
7. Click Next and in the Name textbox give the policy a descriptive name. The Description textbox is optional.
8. Click Next, leave Activate the default response rule checkbox ticked and click Next again.
9. Leave the Edit Properties checkbox ticked and click Finish.
10. The Properties dialog box should be open now. Click Add button and click Next in the wizard.
11. Leave This rule does not specify a tunnel selected and click Next.
12. Leave All network connections selected and click Next.
13. You should now see the IP Filter List step of the wizard. You need to create a new filter, so don’t select any of the default ones, just click Add.
14. Type a descriptive name for the filter list. The Description textbox is optional.
15. Click Add again to start yet another wizard that will create a filter and add it to the list. Click Next.
16. Leave the IP Traffic Source to My IP Address and click Next.
17. For the IP Traffic Destination you could choose A specific IP Address or A specific IP Subnet to block an IP address or a range of IP address.
18. Enter the IP address you would like to block and the Subnet mask if you selected A specific IP Subnet. Then click Next.
19. Leave the protocol type as Any and click Next then Finish.

You now have the IP or a range of IPs blocked from accessing any service the local computer provides.

To Block from Command line

netsh ipsec static add filter filterlist="Banned IPS" srcaddr=121.32.0.0 srcmask=255.252.0.0 dstaddr=me description="121.32.0.0/14" protocol=any srcport=0 dstport=0
Posted in Windows | Tagged , , | Leave a comment