Wednesday, March 3, 2010

recursion restrictions for named.conf

Check /etc/named.conf for recursion restrictions
I'm getting this warning from check server security option in csf :

You have a local DNS server running but do not have any recursion restrictions set in /etc/named.conf. This is a security and performance risk and you should look at restricting recursive lookups to the local IP addresses only
--
solution:
Make backup copy of named.conf
#cp /etc/named.conf /etc/named.conf-backup

#vi /etc/named.conf

The top of your named.conf should look something like:
-------------------------------------------------------------------
include "/etc/namedb/rndc.key";

controls {
inet 127.0.0.1 allow { localhost; } keys { "rndc-key"; };
};


acl "trusted" {
127.0.0.1;
};


options {
pid-file "/var/run/named/named.pid";
directory "/etc/namedb";
dump-file "/var/dump/named_dump.db";
statistics-file "/var/stats/named.stats";
version "BIND";
allow-recursion { trusted; };
allow-notify { trusted; };
allow-transfer { trusted; };
forwarders { 127.0.0.1; };

};
------------------------------

If you don't have the lines in bold, add them to your named.conf (make a backup first!) and restart BIND. You can also add additional IP addresses if you have other servers in the DNS cluster.

Restart bind.

Mysql optimization

=========================================
[mysqld]
set-variable = max_connections=500
safe-show-database
local-infile=0
===========================================
[mysqld]
max_connections = 500
key_buffer = 32M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 4000
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 7000
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 4M
query_cache_size = 12M
query_cache_type = 1
tmp_table_size = 16M
skip-innodb

[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

[mysqlhotcopy]
interactive-timeout

Script Configuration Files

Location of Script Configuration Files

Config file locations.

4Images Gallery
/config.php
B2 Evolution /conf/_basic_config.php
Boonex Dolphin /inc/header.inc.php
Coppermine Photo Gallery /include/config.inc.php
Cube Cart /includes/global.inc.php
dotProject /includes/config.php
Drupal /sites/default/settings.php
FAQMasterFlex /faq_config.php
Gallery /config.php
Geeklog /db-config.php
/siteconfig.php
/lib-common.php
Joomla /configuration.php
Mambo /configuration.php
Moodle /config.php
Noahs Classifieds /app/config.php
Nucleus /config.php
osCommerce /includes/configure.php
/admin/includes/configure.php
PHP-Nuke /config.php
phpBB /config.php
phpFormGenerator (only if you have saved form input to a database)
/forms/admin/config.inc.php
PHPlist /config/config.php
phpWCMS /include/inc_conf/conf.inc.php
phpWebSite /conf/config.php
PhpWiki /admin.php
/lib/config.php
Post-Nuke /config.php
Siteframe /config.php
SMF /Settings.php
Soholaunch /sohoadmin/config/isp.conf.php
TYPO3 /typo3conf/localconf.php
vBulletin /includes/config.php
WebCalendar /includes/settings.php
WordPress /wp-config.php
Xoops /mainfile.php
Zen Cart /includes/configure.php
/admin/includes/configure.php




These paths are relative to the root of the script, not the account nor domain. So if it's a vBulletin forum, under /home/username/www/forum/, the configuration file would be in /home/username/www/forum/includes/config.php

Tuesday, March 2, 2010

Alternative PHP Cache [APC]

How to install Alternative PHP Cache [APC] on a Linux VPS/Dedicated server !

APC
is a free, open, and robust framework for caching and optimizing PHP intermediate code. Here are the most simple steps :

# Login to the server as root

# Download APC
wget http://pecl.php.net/package/APC
eg : wget http://pecl.php.net/get/APC-3.0.15.tgz

# Extract it and move into the directory
tar -xzf APC-3.0.15.tgz
cd APC*

# Locate where php is
which php
This should return something like: /usr/local/bin/php Remember the location of php.

# Create configuration files
phpize

# Compile APC

./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/local/bin/php-config
make
make install

# Install APC into php.ini

You will have to first locate php.ini using the following command

php -i | grep php.ini

This will usually return /usr/local/Zend/etc/php.ini on a server that has Zend optimizer installed. Now edit php.ini and add the APC extension.

vi /usr/local/Zend/etc/php.ini

Scroll down to the bottom and add the fallowing before the lines about the zend optimizer (They start with [Zend])

extension=”/apc_location/apc.so”


# Restart Apache

# Restart Apache




























SOA parameters for a DNS server

To set the SOA parameters for a DNS server, perform the following steps:

1. Set the following parameters

1. Set the following parameters

Parameter Name

Description

Notes

E-mail

the mailbox of the person responsible for this DNS server.

TTL

"time-to-live": the time, in seconds, this DNS server caches (keeps) a piece of information received from your server before it asks your server again.

  • If you set the value too low, your server will get loaded down with too many repeat requests.
  • If you set it too high, the information you change will not get distributed in a reasonable amount of time.
  • By default, 86400 seconds (1 day) is set.

The solution is as follows:

  • If particular information is not expected to change in the near future, one can have a high TTL (anywhere between a day (86400 seconds) and a week (604800 seconds)
  • If information is known to change soon, it can be transmitted with a low TTL (an hour to a day).

It is standard practice to reduce the TTL transmitted with information that is scheduled to change in order to make that change visible rapidly throughout the Internet; once the change has happened, the TTL is increased again.

Refresh

the time interval, in seconds, before which the zones need to be updated.

  • By default, 10800 (3 hours) is set.
  • A good value here would be 3600 (1 hour).

Retry

the time interval, in seconds, after which the next attemp of refresh should be taken, after a refresh failure.

  • By default, 3600 (1 hour) is set.
  • A good value here would be 600 (10 minutes).

Expire

the upper limit, in seconds, on the time interval that can elapse before the zones are no longer authoritative

  • By default, 604800 (7 days) is set.
  • A nice value here would be 3600000 (42 days).

Minimum TTL

the minimum number of seconds to be used for TTL value in RRs.

By default, 86400 (1 day) is set, which is a good value.

Virtuozzo Configuration Files

Matrix of Virtuozzo Configuration Files

There are a number of files responsible for the Virtuozzo system configuration. Most of the files are located in the /etc directory on the Hardware Node. However, some configuration files are stored in the /etc directory inside the Service Container, on the Backup Node, inside a Container, or on a dedicated server. In case a configuration file is located in a place other than the Hardware Node, we point clearly the exact position (the Service Container, etc.) where it can be found.

A list of configuration files is presented in the table below:

/etc/vz/vz.conf

The Virtuozzo global configuration file. This file keeps system-wide settings, affecting Container and Virtuozzo template default location, global network settings and so on.

/etc/vz/conf/<CT_ID>.conf

The private configuration file owned by a Container numbered <CT_ID>. The file keeps Container specific settings – its resource management parameters, location of private area, IP address and so on.

/etc/vz/conf/ve-<name>.conf.sample

Sample files, containing a number of default Container configurations, which may be used as a reference for Container creation. The following samples are shipped with Virtuozzo: basic, cpanel, confixx, slm.plesk, slm.256MB, slm.512MB, slm.1024MB, slm.2048MB. You may also create your new samples customized for your own needs.

/etc/vz/conf/dists/<distribution_name>.conf

The configuration files used to determine what scripts are to be run on performing some operations in the Container context (e.g. on adding a new IP address to the Container). These scripts are different from Virtuozzo action scripts and depend on the Linux version the given Container is running.

/etc/sysconfig/vzsve

The configuration file used for the Service Container creation by vzsveinstall.

/etc/sysconfig/vzagent/<file>

Parallels Agent configuration files.

/etc/vz/conf/networks_classes

The definition of network classes, used by traffic shaping and bandwidth management in Virtuozzo.

/etc/sysconfig/vzup2date/vzup2date.conf

This file specifies the default connection parameters for the vzup2date utility.

/<path>/<name>.conf

This configuration file specifies the default connection parameters for the vzup2date-mirror utility. It should be located on the computer where you are planning to run vzup2date-mirror.

/etc/cron.d/vereboot

The configuration file for the cron daemon. Using this file, Virtuozzo emulates the "reboot" command working inside a Container.

/etc/vzvpn/vzvpn.conf

The configuration file used to define the parameters for establishing a private secure channel to the Parallels support team server.

/etc/vzreport.conf

The configuration file used to define the parameters for sending your problem report to the Parallels support team.

/etc/sysctl.conf

Kernel parameters. Virtuozzo adjusts a number of kernel sysctl parameters, and modifies the default /etc/sysctl.conf file.

/etc/vzredirect.d/*.conf

These files define the offline management modes for controlling Containers by Container administrators.

/etc/vzlmond.conf

This configuration file defines the parameters used by the vzlmond daemon to collect information on the main Hardware Node resources consumption.

/etc/vzstat.conf

The file lists the warning and/or error levels for a number of resource control parameters. If a parameter hits the warning or error value, the vzstat utility will display this parameter in yellow or red.

/etc/vzstatrep.conf

This configuration file is located on the Monitor Node and used by the vzstatrep utility when generating statistic reports and graphics on the Hardware Node resource consumption and sending these reports to the Node administrator.

/etc/vzbackup.conf

The global configuration file residing on the Backup Node and determining the global Container backup settings.

/etc/vz/pkgproxy/rhn.conf

The Red Hat Network (RHN) Proxy Server configuration file used by the vzrhnproxy utility when setting up the RHN Proxy Server. This file can be located on any computer where the vzrhnproxy package is installed.

/etc/vzpkgpoxy/vzpkgproxy.conf

This configuration file is used by the vzpkgproxy utility when creating special caching proxy servers for OS and application EZ templates. The file can be located on any computer where the vzpkgproxy package is installed.

/etc/vztt/vztt.conf

This configuration file is used by the vzpkg utility when managing OS and application EZ templates.

Install XCache

XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested (on linux) and supported on all of the latest PHP. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce server load.

To install follow the steps

1. Download and extract the source for XCache .

# cd /usr/local/src/
# wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
# tar -xzvf xcache-1.2.2.tar.gz

2. Build, configure and install the XCache module.
# cd xcache-1.2.2
# phpize
# ./configure --enable-xcache
# make && make install

You can see a message like this . Note the extension directory.

=============
Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
==============

3. Now configure the php.ini file ( To find .ini file, use the command `php -i | grep php.ini` )

# cat xcache.ini >> /usr/local/lib/php.ini

Replace the following line in php.ini with correct path ,which describes the Installed shared extensions that we noted above.

zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so

It will become like this,

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so

4. Restart apache and confirm the Xcache installation.
# /etc/init.d/httpd restart

# php -v

it will show you as
-----------
php -v
PHP 5.2.8 (cli) (built: Feb 16 2009 05:42:38)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
--------