Archive for June, 2007

If you are getting “under current configuration sql server studio express doesnot support remote connection”. error while conneting microsoft sql server 2005 please do following step

1)Please go to Start >> Programs >> Microsoft SQL Server 2005 >> Congfiguration Tools >> SQl Server Configuration manager then expand SQL server 2005 Network configuratiion >> Protocal for SQLEXPRESS and enable named pipes and TCP/IP protocal.

2)Make sure to restart the MSSQLSERVER service after enabling the TCP/IP and named pipes.

If you did so and its not still not working, try the following steps:

* Make sure your sql service is running, use either “net start” or “sc query <InstanceName>” or run services.msc, check status of the server; If server start fail, go to ERRORLOG to see what happened there, fix the problem and restart server.

* You might explicitly use “np:”prefix which ask for connect through named pipe. However, client can not connect to server through the pipe name that specified.Double check the server is started and listening on named pipe if you enabled Named Pipe. One way is that see the ERRORLOG of the server, search follow keywords:

Server named pipe provider is ready to accept connection on [ \\.\pipe\sql\query ] or [\\.\pipe\mssql$<InstanceName>\sql\query]

Notice that “sql\query” is the default pipe name, so you need to know server is listening on which pipe name. eg: if you specify server pipe name is “sql\query1″, then you would see in the errorlog that server listening on [ \\.\pipe\sql\query1 ], and go to SQL Server Configuration Manager, click client Named Pipe properties, see whether the pipe name is same with the one server listening on.

*You might specify named pipe protocol in connection string, but did not enable named pipe on the server, check ERRORLOG.

* You might use FQDN/IPAddress/LoopbackIP to connect to the server when only shared memory was enabled, you can change to <machinename> to resolve this.

* You might explictly specify “lpc:” prefix in your connection string, but shared memory was not enabled. To resolve this, either remove the prefix as long as named pipe or tcp was enabled or enable shared memory.

Regard’s

Alex P

IF you disable PHP function in php.ini file and if you want to enable any particular function only one account .Then You can however use suhosin to enable a function for one domain only.

How can you do that ?

After installing suhosin, remove all functions from disable_functions in php.ini and add in php.ini suhosin.executor.func.blacklist = “exec,passthru,shell_exec” and all the functions that you whant to disable globally.
After that for each domain in the virtual host section you can add suhosin.executor.func.blacklist again but without the function that you need to enable. And so you will enable that function only for one domain.

Example:
<VirtualHost 127.0.0.1>
………..
………..
<IfModule mod_php4.c>
php_admin_value open_basedir “/usr/lib/php”
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir “/usr/lib/php”
php_admin_value suhosin.executor.func.blacklist = “passthru,shell_exec”
</IfModule>
…….
……
</VirtualHost>

In this example exec has been enabled for the VirtualHost.
This way it will be better as you do not neet to modify all the virtual hosts only the ones that you need to enable one or more functions.

Regard’s

Alex P

 

22
Jun

How to Install memcached ?

   Posted by: admin    in Linux

memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load.

memcached is meant to work in concert with something like the MySQL query cache, not replace it. The two implementations excel at vastly different things: memcached is an object cache, while MySQL provides a query cache.

memcached is extremely fast. It uses libevent, which provides a mechanism to execute a callback function when a specific event occurs on a file descriptor, to scale to any number of open connections. On a modern Linux system memcached utilizes epoll, is completely non-blocking for network I/O, ensures memory never gets fragmented, and uses its own slab allocator and hash table to achieve 0(1) virtual memory allocation.

How it install

curl -O http://www.monkey.org/~provos/libevent-1.1a.tar.gz
tar zxf libevent-1.1a.tar.gz
cd libevent-1.1a
./configure
make
make install
cd ..
curl -O http://www.danga.com/memcached/dist/memcached-1.1.12.tar.gz
tar zxf memcached-1.1.12.tar.gz
cd memcached-1.1.12
./configure
make
make install


Then add /usr/local/lib to LD_LIBRARY_PATH in your .bash_profile


LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

export LD_LIBRARY_PATH

How it Works

First, you start up the memcached daemon on as many spare machines as you have. The daemon has no configuration file, just a few command line options, only 3 or 4 of which you’ll likely use:

# /usr/local/bin/memcached –d –l x.x.x.x –u nobody –m 32 –p 11000

This starts memcached as a daemon (–d) on the IP address and port specified with –l and –p, respectively, running as the user nobody (–u), allocating 32 MB for object storage (–m). You should adjust the amount of storage to suit your needs; many memcached installs run with 4 GB. Once you’re comfortable with your startup options, add the appropriate command to your startup scripts.

With memcached installed and running, it’s time to get PHP talking to the object cache. While multiple PHP API’s exists, the one in the PECL repository is recommended. If you’re running a newer version of PHP, installation is as simple as:

# pecl install memcache

7
Jun

Install CDONTS Windows 2003

   Posted by: admin    in Window

        By default CDONTS is NOT INSTALLED on Windows 2003, but CDOSYS is. CDOSYS is an updated version of CDONTS, but more than likely you will need CDONTS for compatibility issues.
However, some ASP scripts will require CDONTS and customers can need CDONTS install.
1) First, install MailEnable or other SMTP server. Make sure it is running.
2) Download and unzip cdonts.dll to C:\Windows\System32 folder
3) Register the CDONTS.DLL component on your server by clicking start >> run >> type : cmd
a)The Command Prompt window will open as shown below.
b)At the flashing cursor, type in CD \windows\system32 and press enter.
c)Now, at the flashing cursor type in RegSvr32 cdonts.dll and press enter.

Now CDONTS should being work perfectly.

To know if CDONTS is installed you can use http://www.pensaworks.com/prg_com.asp to view a list of installed components.

Based on: http://www.windows-2003-hosting.co.uk/?pagename=cdontshowto

2
Jun

How to check DDos attack ?

   Posted by: admin    in Server-Security

A quick and useful command for checking if a server is under ddos is:

netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

That will list the IPs taking the most amounts of connections to a server. It is important to remember that the ddos is becoming more sophisticated and they are using fewer connections with more attacking ips. If this is the case you will still get low number of connections even while you are under a DDOS.

Another very important thing to look at is how many active connections your server is currently processing.

netstat -n | grep :80 |wc -l

netstat -n | grep :80 | grep SYN |wc -l

The first command will show the number of active connections that are open to your server. Many of the attacks typically seen work by starting a connection to the server and then not sending any reply making the server wait for it to time out. The number of active connections from the first command is going to vary widely but if you are much above 500 you are probably having problems. If the second command is over 100 you are having trouble with a syn attack.

To Block a certain IP address that on server .Please use following commands

—————–command——————————

route add ipaddress reject

for example route add 192.168.0.168 reject

You can check whether given IP is blocked on server by using following command

route -n |grep IPaddress

—————–command——————————

OR

use follwoing command to block a ip with iptables on server
—————–command——————————
iptables -A INPUT -s IPADRESS -j DROP/REJECT

service iptables restart

service iptables save

—————–command——————————

Then KILL all httpd connection and restarted httpd service by using following command

killall -KILL httpd

service httpd startssl
Regard’s

Alex

mysql_pconnect() will maintain a persistent connection to the database. Whenever your script calls the connect to database function, it first searches already existing connections to the database and if exists it will use the same connection to connect to the database, if not it will open a new connection to the database. ie. Connection is Persistent

where as mysql_connect() function will establish a new connection whenever a connection to database needed, and after executing the script, this function disconnects the connection. ie. connection is not a persistent one.

mysql_pconnect() function is used where your site has a Heavy Traffic and where as mysql_connect() function is used when there is moderate/less traffic to your site.

Regard’s

Alex P

System Administrator.