Archive for the tag 'Files'

SBDavid

Postfix configuration files

Postfix configuration files

By default, Postfix configuration files are in /etc/postfix. The two most important files are main.cf and master.cf; these files must be owned by root. Giving someone else write permission to main.cf or master.cf (or to their parent directories) means giving root privileges to that person.

In /etc/postfix/main.cf you will have to set up a minimal number of configuration parameters. Postfix configuration parameters resemble shell variables, with two important differences: the first one is that Postfix does not know about quotes like the UNIX shell does.

You specify a configuration parameter as:

/etc/postfix/main.cf:
parameter = value

and you use it by putting a “$” character in front of its name:

/etc/postfix/main.cf:
other_parameter = $parameter

You can use $parameter before it is given a value (that is the second main difference with UNIX shell variables). The Postfix configuration language uses lazy evaluation, and does not look at a parameter value until it is needed at runtime.

SBDavid

How to force php files to use CLI

How to force php files to use CLI

To force php files to use CLI (on the assumption your default php version uses suPHP) create an .htaccess file in your public_html directory, with the following:

<FilesMatch “\.php$”>
AddHandler application/x-httpd-php .php
</FilesMatch>

As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. As the name implies, this SAPI type main focus is on developing shell (or desktop as well) applications with PHP. There are quite a few differences between the CLI SAPI and other SAPIs which are explained in this chapter. It’s worth mentioning that CLI and CGI are different SAPI’s although they do share many of the same behaviors.

The list of command line options provided by the PHP binary can be queried anytime by running PHP with the -h switch

More: http://in2.php.net/manual/en/features.commandline.php

.htaccess Hotlink protection for files on your server.

You can stop others from hotlinking your site’s files by placing a file called .htaccess in your Apache site root (main) directory. The period before the name means the file is hidden.

Example: Your site url is www.mysite.com. To stop hotlinking of your images from other sites and display a replacement image called nohotlink.jpe placed in your images directory, place this code in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/blockhotlink.jpe [L]

The first line of the above code begins the rewrite. The second line matches any requests from your own mysite.com url. The [NC] code means “No Case”, meaning match the url regardless of being in upper or lower case letters. The third line means allow empty referrals. The last line matches any files ending with the extension jpeg, jpg, gif, bmp, or png. This is then replaced by the blockhotlink.jpe file in your images directory. This JPEG image is using the extension jpe instead of jpg to prevent blocking your own replacement image.

SBDavid

Internal Server Error with cgi files

Internal Server Error with cgi files

This means that the cgi script did not execute properly. There are several causes that can generate this error so a few things would need to be checked.

1) check the /var/log/httpd/suexec_log. It contains any errors that would be as a result of not having correct permissions on the file.

2) The file needs to be in a cgi-bin and must have the owner/group as the username who owns the site.

3) The script must have execute permission.

4) The most common chmod permission is 755.

5) The easiest way to figure out script coding problems is to first run the script manually from an ssh prompt.

6) Other errors that would be generated when running the script manually from ssh would be missing perl modules.

7) Cpan is the easiest method to install new perl modules, eg:

perl -e shell -MCPAN
install Bundle::DBD::mysql

Using Perl to make changes to your DNS files

Example : You would like to change “v=spf1 a mx ip4:1.2.3.4 ?all” to “v=spf1 a mx ip4:1.2.3.4 -all”

of course, where 1.2.3.4 should be replaced by your server IP.

If you’d rather do this to all of your domain, you can use perl

cd /var/named

perl -pi -e ’s/\?all/\-all/’ *.db

change /var/named to the appropriate directory for your db files for your OS (/etc/bind, /etc/namdb)

Restart named after making the changes.

« Prev - Next »