February 23, 2010 | Posted by
admin | Category: Linux Administration
Your perl script sometimes work from the command line but shows “Internal Server Error” on accessing the script via the browser. The Apache error logs shows the error message as
"Can't do setuid (cannot exec sperl)".
The the reason for the setuid error on the perl script is the script have the setuid bit set and won’t work from the browser since they are running under the user apache. To make such perl scripts work, you need to install the perl-suidperl package.
To install the package, just execute the command
# yum install perl-suidperl
Comments Off on Perl Script: Can’t do setuid (cannot exec sperl)
February 6, 2010 | Posted by
admin | Category: Linux Administration
You may see quite a few maildrop warning messages in the postfix logs such as
postdrop: warning: mail_queue_enter: create file maildrop/xxxx.xxxx: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/yyyy.yyyy: Permission denied
The error occurs when postfix is not able to write under the “maildrop” folder and hence unable to send emails. This is due to incorrect ownership on the ‘maildrop’ folder i.e. the “maildrop” folder is not owned by ‘postfix’.
Check the ownership/permissions of the postfix files:
# /etc/init.d/postfix check
postfix/postfix-script: warning: not owned by postfix: /var/spool/postfix/public
postfix/postfix-script: warning: not owned by postfix: /var/spool/postfix/maildrop
Solution:
Stop the postfix service:
# /etc/init.d/postfix stop
Kill the postdrop processes:
# killall -9 postdrop
Correct the ownership of the above directories:
# chown postfix.postdrop /var/spool/postfix/public -R
# chown postfix.postdrop /var/spool/postfix/maildrop -R
Now, start the postfix service:
# /etc/init.d/postfix start
Emails should now be working fine.
December 27, 2009 | Posted by
admin | Category: Linux Administration
How to redirect a website using .htaccess?
Redirect website http://mydomain.com to http://www.mynewdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^(.*)$ http://www.mynewdomain.com [R=301,L]
Redirect website mydomain.com with and without www requests to http://www.mynewdomain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^(.*)$ http://www.mynewdomain.com [R=301,L]
Redirect requests from http://mydomain.com to http://mydomain.com/subdirectory i.e. redirecting requests from main domain to a sub-directory.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^(.*)$ http://www.mydomain.com/subdirectory/ [R=301,L]
Redirect all http (80) requests of a domain to https (443) i.e. redirecting requests from non-secure port to a secure port.
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L]
Comments Off on How to redirect a website using .htaccess?
December 21, 2009 | Posted by
admin | Category: Linux Administration
You may see the tty device error messages like ‘/dev/tty1: cannot open as standard input: Permission denied’ in the server logs and many more like
Jan 10 xx:xx:xx [agetty] /dev/tty1: cannot open as standard input: Permission denied
Jan 10 xx:xx:xx [agetty] /dev/tty2: cannot open as standard input: Permission denied
Jan 10 xx:xx:xx [agetty] /dev/tty3: cannot open as standard input: Permission denied
Jan 10 xx:xx:xx [init] Id “c1” respawning too fast: disabled for 5 minutes
Jan 10 xx:xx:xx [init] Id “c2” respawning too fast: disabled for 5 minutes
Jan 10 xx:xx:xx [init] Id “c3” respawning too fast: disabled for 5 minutes
The tty “Permission denied” error message is because of the misconfiguration in your /etc/inittab file in which case you have to edit the file and comment the agetty/getty lines. Login to your server as root and edit the file:
pico /etc/inittab
Search for the lines
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
and comment the lines by placing a # in front of them.
Save the file and you won’t see the messages.
OR
you may try re-creating the terminals again from shell as root. Login to your server as root and execute the command:
/sbin/makedev /dev/tty1
and replace 1 with 2,3,4,5,6,7 for other terminals and reboot the server.
December 14, 2009 | Posted by
admin | Category: Linux Administration
What is .htaccess and how to disable .htaccess?
.htaccess is use to modify the way Apache behaves for a directory and it’s sub-directories. It gives you an extra control on your server, like setting up custom error messages, password protect a directory, writing rewrite rules, blocking IPs etc.
However, it can be a potentially dangerous file. For example, a hacker can redirect your website to an external website say a malware website.
In order to disable .htaccess server wide, edit the Apache configuration file
pico /etc/httpd/conf/httpd.conf
Search for
AllowOverride All
replace it with
AllowOverride None
Save the file and restart the Apache service.
service httpd restart
Comments Off on What is .htaccess and how to disable .htaccess?