Saturday 31 October 2009

How to install memcache on linux server?

Or you can use following steps to install PECL memcache manually.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 it on Linux server ?
#curl -O http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
#tar -xzvf libevent-1.4.9-stable.tar.gz
#cd libevent*
#./configure
#make
#make install

Now let’s download the newest Memcached source
#curl -O http://www.danga.com/memcached/dist/memcached-1.3.0.tar.gz
#tar zxf memcached-1.3.0.tar.gz
#cd memcached-1.3.0
#./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:

Run Memcached as a daemon (d = daemon, m = memory, u = user, l = IP to listen to, p = port)
#memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 –u nobody

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 1024  for object storage (-m). You should adjust the amount of storage to suit your needs; many memcached installs run with 4 GB. Once you are comfortable with your startup options, add the appropriate command to your startup scripts.

Create a /etc/init.d/memcached file and add above line to start memcached when the server boots With memcached installed and running, it’s time to get PHP talking to the object cache. While multiple PHP API exists, the one in the PECL repository is recommended. If you are running a newer version of PHP, installation is as simple as:
# pecl install memcache

Or you can use following steps to install PECL memcache manually.
#cd /usr/local/src
#curl -O http://pecl.php.net/get/memcache
#tar zxvf memcache*
#cd memcache-*
#phpize
#./configure
#make && make install

Now we have to make sure PHP loads the newly built memcache.so library by adding the following line to php.ini:

extension=memcache.so

Now restart Apache:
Service httpd restart

Once it sucussfully install you can create phpinfo() on your webserver should now confirm that memcache is installed.

Wednesday 28 October 2009

Error codes : FTP

FTP is most widely used application using which you can manage upload download data for your website/server. While using FTP program you may come across many error or message which you need to understand and will have to react accordingly.
Following are few of them which you should know.
421 -: too many users logged to the same account.

530 -: It represent that wrong login password has been used


550 -: If the file exist it means you have no access to the file or dir. 550 error message stats that the account you have currently logged in does not have permission to perform the action you are trying to execute or you may be trying to upload to the wrong directory or trying to delete a file.


120 :- Service ready in nnn minutes.


125 :-  Transfer of data started, data connection is with server is open


150 :- File status okay; about to open data connection.


200 :- no error with fired command.


202 :- specified command is not implemented


211 :- System status


212 :- Shows directory status.


213 :- shows file status.


214 :- you can get meaning of a particular non-standard command very useful for non technical support guys.


220 :- Service ready for new user.


221 :- it stats that particular service is closing control connection.


225  :- Data connection open; no transfer in progress.


226  :- Closing data connection.


227  :- Entering Passive Mode


230  :- User logged in, proceed.


250  :- Requested file action okay, completed.


331  :- User name okay, need password.


332  :- Need account for login.


350  :- Requested file action pending further information


421  :- Service not available, closing control connection.


425  :- Can’t open data connection.


426  :- It indicates that connection is closed; and transfer is aborted.


450  :- Requested file action not taken.


451  :- Requested action aborted. Local error in processing.


452  :- Requested action not taken may be due to insufficient storage space in system.File unavailable (e.g., file busy).


500  :- Syntax error, command unrecognized. This may include errors such as command line too long.


501 :-  Syntax error in parameters or arguments.


502  :- Command not implemented.


503  :- Bad sequence of commands.


504  :- Command not implemented for that parameter.


530  :- Not logged in.


532  :- Need account for storing files.


550  :- Requested action not taken. Reason : File unavailable (e.g., file not found, no access).


551  :- Requested action aborted. Reason :  Page type unknown.


552  :- Requested file action aborted due to exceeded storage allocation (for current directory or dataset).


553  :- Requested action not taken. File name not allowed.

Setting or Changing MYSQL Root Password

Setting/changing MYSQL root Password
Setting up mysql database password is one of the important tasks which a webmaster should take care of. If you have never set a root password for MySQL, then
server does not require a password at all for connecting as root and if you have already set password for your database and for some reason if you want to change it then you can do so using following commands.
To setup root password for
MySQL databases for first time you need to login to your server as root and will have to use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password “mysql_password“


However, if you want to change/update your root password, then you will have to use following command



$ mysqladmin -u root -p oldpassword newpassword


after you fire above command you will have to provide password for your MySQL database.

Fantastico error : Fantastico is not installed at the default location

Many webmaster having cPanel server may get following error when you try to install/upgrade fantastico on your cPanel server. You may get few complaints from your customers stating that when they try to access fantastico they get below error code.
” I got this error when I click on the fantastico button in Cpanel.  Fantastico is not installed at the default location “
/usr/local/cpanel/3rdparty/fantastico. Either move the Fantastico
directory from it’s current location to
/usr/local/cpanel/3rdparty/fantastico OR enable ioncube loaders in WHM ->
Tweak settings “


For this error you will have to update your cpanel version to latest version.  You can also set your server for auto
cpanel update using following settings :


  • Login to your WHM > Choose “Update Config” > Tick “Automatic (Stable Tree)”you need to check if ioncube is installed on server and it should be enable in WHM -> Tweak settings.

  • you can update fantastico manually using following command cd /usr/local/cpanel/whostmgr/docroot/cgi/fantastico/scripts/ ; /usr/local/cpanel/3rdparty/bin/php cron.php

  • You can also rebuild cpanel’s php using /scripts/makecpphp

  • You can also force cpanel update using following command /scripts/upcp –force



Once your server is updated, you may be able to install Fantastico again and can use it easily without any problem.

How to add a range of IPs on a BSD box.

FreeBSD is a popular free Unix like open source operating system that is based on the Berkeley Software Distribution (BSD) version of the Unix operating system. FreeBSD runs only on the Intel PC platform (i386 and higher) having atleast Pentium processor and also on amd64, Alpha/AXP, IA-64, PC-98 and UltraSPARC processors. You can consider FreeBSD as an alternative to Linux which will run Linux applications. Its said that its fast, stable, and is appropriate for Internet server or as a file server. FreeBSD supports all major X Window desktops, such as KDE and GNOME.



If you want to add Dedicated IPs on server having FreeBSD you need to follow following instructions.
First login to your FreeBSD server as a ‘non-root’ user. You should have an account in the ‘
wheel’ group. Once you logged in your server just run the following commands to switch users to ‘root’

su -
Password:
server#


you will get command prompt as ‘#’ which indicates that you are operating server as ‘root’ user. Now run following commands as root :
ee /etc/rc.conf

now for example, if we want to add 4 IPs for your server [ 192.168.1.3 - 192.168.1.6 ] you need to implement following :
Code:
ifconfig_fxp0=”inet 192.168.1.2 netmask 255.255.255.248?
ifconfig_fxp0_alias0=”inet 192.168.1.3 netmask 255.255.255.255?
ifconfig_fxp0_alias1=”inet 192.168.1.4 netmask 255.255.255.255?
ifconfig_fxp0_alias2=”inet 192.168.1.5 netmask 255.255.255.255?
ifconfig_fxp0_alias3=”inet 192.168.1.6 netmask 255.255.255.255?

Note that changes to the _aliasNN and also the netmask changes to 255.255.255.255 from 255.255.255.248. The IP’s will not work unless you use a 255.255.255.255 netmask for the alias IP’s.



Once you added the entries to your file you need to press ‘ESC’ and have to save this file. You need to reboot the server so that all new IP’s would get bounded with your server and you can use them.
You have other option too, you can also use
ifconfig command for adding IP’s on your server, in this case you don’t have to reboot your server. You can also add extra Dedicated IPs if you have WHM/cPanel control panel with your server. just login to your WHM account and add new Dedicated IP using WHM >> Add a new IP.

Installing SSL on server using WHM

Almost all webmaster try to have SSL certificate on their ecommerce sites so that all transactions can be done securely. Domain which need to have SSL certificate should be hosted on dedicated IP where you can install SSL certificate for it. You can order SSL certificate from any provider and can install it for your domain. Once you have generated or received an SSL certificate, you can install the certificate using WebHost Manager. You need to have both the certificate and key files to install the certificate. Following steps would be helpful for you to install SSL certificate.
*) Login to WHM.
*) Click on Install an SSL Certificate and Setup the Domain under the SSL/TLS menu.
*) Enter the domain, user name, and IP address for the certificate in the Domain, User, and IP Address fields.
*) Click on the Fetch button to paste the .key and .crt files for the domain into the fields, if they are currently on your server. Otherwise, copy and paste the .key and .crt files into the available display areas.
*) Paste the ca bundle for the certificate in the bottom display area
*)Click on the Submit button.
that’s all you have successfully installed an SSL certificate for req

How to trap cPanel ( WHM ) Password Modification

If your account is hosted on Linux hosting server then most webhosting service provider will offer you WHM/cPanel as hosting control panel depending on hosting package you choose. WHM/cpanel offer you large number of features using which you can manage your hosting account or website very easily. you can set/reset password of cpanel, can manage email accounts, hosting accounts, can easily disk quota, create FTP accounts, setup CMS etc….. Most important feature you have with these control panels is that you can change password of cpanel using cpanel aswell as WHM. You may have to change reset your control panel password for some security reason, thus this feature is very important for all webmasters.


If you want to know the password which have changed password of cpanel then you need to create a module in /usr/local/Cpanel/ChangePassword/. This will run as root when password is changed in WHM or cPanel.



Module features :
You can access following variables using above module :
- user (string) - Account Username
- newpass (string) - Account Password
- message (string)*** - Password Change Status Message
- rawout (string)*** - Password Change output
- service_ref (string)*** - Password Change Service

Thus in order to access above module you will have to do the following :



#!/usr/bin/perl
package Cpanel::ChangePassword::Sendtobilling;
use strict;



my %OPTS = @_;
my $user = $OPTS{’user’};
my $newpass = $OPTS{’newpass’};
#Add function to create object and password send

Username / Password can then be send to remote location thus you can retrieve password which have tried to change password of cpanel.

Unblock IP using CSF firewall - VPS server

Following steps would help you to Unblock IP address you have blocked through CSF firewall. First of all you need to login to your VPS server using SSH access, then need to access APF firewall located under /etc/csf
you just need to edit csf.deny using vi csf.deny you need to remove IP address which you want to unblock from this file. Once you have edited above file you need to restart Firewall. For restarting Firewall you can use csf –r


Unblock IP using CSF firewall on VPS server

Secure backup server

Backups plays an important role when your server crash and you lost all your data, you can restore all your webfiles and can get your site up and running through your offsite backupaccount. Usually all webhosting service provider will offer you backup space on their remote server where you can upload backup copies of your webfiles, databases. If  you are connecting your server backup using some custom software or script then there can be a risk for using such custom applications as if your local machine gets compromised then hacker can easily login to your remote backup space and can delete all your data through this custom software. Thus its always recommended to go with a host who don’t use any such custom application for allowing users to login to your backup space rather go with a webhost who would initiates data transfer from their remote backup servers (using scp scripts or RSYNC over SSH) – thus your server doesn’t have a direct access to backup data directory. This will avoid any backup data loss as if you are using any custom application software for connecting to your backup server and your local machine gets hacked then hacker can easily login to your remote backup server and can delete all data from your server. Its better to check with your webhost about what kind of connection do they offer you for connecting with your remote server. Don’t go with any host who is offering you some script or software for getting

Tuesday 27 October 2009

Error : Upgrading to 2.8.5 Wordpress

I was getting a error while upgrating wordpress to 2.8.5- Downloading update from http://wordpress.org/wordpress-2.8.5.zip.
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2354937 bytes) in /home1/ottousco/satmareanul.com/wp-includes/http.php on line 1324

Might need to increase the amount of memory a PHP script may consume

1. If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 64M:
memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

2. If you don't have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M

3. Try adding this line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '64M');

4. Talk to your host.

Monday 26 October 2009

Exim Error: Ratelimit database not available

2009-07-20 21:58:07 Failed to get write lock for /var/spool/exim/db/ratelimit.lockfile: timed out
2008-07-20 21:58:07 H=[xx.xx.xx.xx] temporarily rejected connection in “connect” ACL: ratelimit database not available

To fix such an error , the exim cache database on the server side needs to be clear off to stop this message.


Run the folllowing command on root :



# rm -fv /var/spool/exim/db/*

Output :



removed `/var/spool/exim/db/ratelimit’
removed `/var/spool/exim/db/ratelimit.lockfile’
removed `/var/spool/exim/db/retry’
removed `/var/spool/exim/db/retry.lockfile’
removed `/var/spool/exim/db/wait-dk_remote_smtp’
removed `/var/spool/exim/db/wait-dk_remote_smtp.lockfile’
removed `/var/spool/exim/db/wait-remote_smtp’
removed `/var/spool/exim/db/wait-remote_smtp.lockfile’

Then run the following command on root:


# service exim restart


If this doesn’t work , then run /scripts/upcp –force on the server and then check exim_mainlog for the changes.

Sunday 25 October 2009

Password protecting a directory with Apache and .htaccess

The Apache web server can read .htaccess files located anywhere in your document root to perform different tasks and control settings without changing the configuration files. This may be useful where you don't have access to change the configuration files or don't want to mangle with the configuration files to perform easy tasks. In this tutorial we're going to password protect a single directory on your web site.


First we'll need to create a file containing users and passwords:



htpasswd -c /etc/apache2/.htpasswd user1
htpasswd /etc/apache2/.htpasswd user2

You can store the password file anywhere you like but I chose to store it where the Apache configuration files are located.


Now create a .htaccess file in the folder you wish to protect (pico /var/www/secret/.htaccess)



AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
AuthName "Enter password"
Require valid-user

Make sure Apache allows .htaccess to override settings. Add these lines into your virtual host configuration and change the directory to your document root (pico /etc/apache2/sites-enabled/000-default):




AllowOverride All


The AllowOverride setting may already be in your virtual host configuration. Make sure it is set to All.


If you changed the AllowOverride setting, restart Apache:



/etc/init.d/apache2 restart

The directory should now be password protected.


If you are getting server errors, make sure the Apache user has permission to read both the .htaccess file and .htpasswd.



chmod 755 /var/www/secret/.htaccess
chmod 755 /etc/apache2/.htpasswd

Monitoring PowerDNS with MRTG

Monitoring PowerDNS is easy with MRTG, just install these two packages and create a config file and you're good to go!



apt-get install libsnmp-session-perl mrtg

Add this to a config file, for example /etc/mrtg.cfg (pico /etc/mrtg.cfg)



Interval: 5
WorkDir: /var/www/mrtg
WriteExpires: yes
Options[_]: growright,nopercent
XSize[_]: 600

Target[udp-queries]: `/etc/init.d/pdns mrtg udp-queries udp-answers`
Options[udp-queries]: growright,nopercent,perminute
MaxBytes[udp-queries]: 600000
AbsMax[udp-queries]: 600000
Title[udp-queries]: Queries per minute
PageTop[udp-queries]:

Queries per minute


WithPeak[udp-queries]: ymwd
YLegend[udp-queries]: queries/minute
ShortLegend[udp-queries]: q/m
LegendI[udp-queries]: udp-questions
LegendO[udp-queries]: udp-answers

Target[perc-failed]: `/etc/init.d/pdns mrtg udp-queries udp-answers`
Options[perc-failed]: growright,dorelpercent,perminute
MaxBytes[perc-failed]: 600000
AbsMax[perc-failed]: 600000
Title[perc-failed]: Queries per minute, with percentage success
PageTop[perc-failed]:

Queries per minute, with percentage success


WithPeak[perc-failed]: ymwd
YLegend[perc-failed]: queries/minute
ShortLegend[perc-failed]: q/m
LegendI[perc-failed]: udp-questions
LegendO[perc-failed]: udp-answers

Target[packetcache-rate]: `/etc/init.d/pdns mrtg packetcache-hit udp-queries`
Options[packetcache-rate]: growright,dorelpercent,perminute
Title[packetcache-rate]: packetcache hitrate
MaxBytes[packetcache-rate]: 600000
AbsMax[packetcache-rate]: 600000
PageTop[packetcache-rate]:

packetcache hitrate


WithPeak[packetcache-rate]: ymwd
YLegend[packetcache-rate]: queries/minute
ShortLegend[packetcache-rate]: q/m
LegendO[packetcache-rate]: total
LegendI[packetcache-rate]: hit

Target[packetcache-missrate]: `/etc/init.d/pdns mrtg packetcache-miss udp-queries`
Options[packetcache-missrate]: growright,dorelpercent,perminute
Title[packetcache-missrate]: packetcache MISSrate
MaxBytes[packetcache-missrate]: 600000
AbsMax[packetcache-missrate]: 600000
PageTop[packetcache-missrate]:

packetcache MISSrate


WithPeak[packetcache-missrate]: ymwd
YLegend[packetcache-missrate]: queries/minute
ShortLegend[packetcache-missrate]: q/m
LegendO[packetcache-missrate]: total
LegendI[packetcache-missrate]: MISS

Target[latency]: `/etc/init.d/pdns mrtg latency`
Options[latency]: growright,nopercent,gauge
MaxBytes[latency]: 600000
AbsMax[latency]: 600000
Title[latency]: Query/answer latency
PageTop[latency]:

Query/answer latency


WithPeak[latency]: ymwd
YLegend[latency]: usec
ShortLegend[latency]: usec
LegendO[latency]: latency
LegendI[latency]: latency

Target[recursing]: `/etc/init.d/pdns mrtg recursing-questions recursing-answers`
Options[recursing]: growright,nopercent,gauge
MaxBytes[recursing]: 600000
AbsMax[recursing]: 600000
Title[recursing]: Recursive questions/answers
PageTop[recursing]:

Recursing questions/answers


WithPeak[recursing]: ymwd
YLegend[recursing]: queries/minute
ShortLegend[recursing]: q/m
LegendO[recursing]: recursing-questions
LegendI[recursing]: recursing-answers

Make mrtg create a new report every 5 minutes by adding the following line in crontab (type crontab -e):



0,5,10,15,20,25,30,35,40,45,50,55 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg

Create a summary page showing all graphs:



indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

If using the default mrtg/apache configuration you can access the graphs here: http://yourserver/mrtg

Installing PowerDNS on etch/lenny

The PowerDNS Nameserver is a modern, advanced and high performance authoritative-only nameserver. It is written from scratch and conforms to all relevant DNS standards documents. Furthermore, PowerDNS interfaces with almost any database.


This tutorial has been tested and is working on Debian etch and lenny


1. Install the PowerDNS server and MySql backend using apt



apt-get install pdns-server pdns-backend-mysql

2. Create a new database (or use existing) and execute the following SQL queries to create the PowerDNS table structure:



create table domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
)type=InnoDB;


CREATE UNIQUE INDEX name_index ON domains(name);

CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
)type=InnoDB;

CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);



create table supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

3. Configure PowerDNS to use the MySql backend by adding this line into the configuration file (pico /etc/powerdns/pdns.conf)



launch=gmysql

4. Configure MySql login information for the PowerDNS server that can read from the tables you created earlier by adding lines similar to these (pico /etc/powerdns/pdns.d/pdns.local)



gmysql-host=127.0.0.1
gmysql-user=pdns
gmysql-password=password
gmysql-dbname=pdns

Replace the username, password and dbname with a valid login information and database name.


5. Restart PowerDNS



/etc/init.d/pdns restart

Now you should have a fully functional PowerDNS server installed. To manage the database (adding zones and records), consider using the Poweradmin web-based administration tool.

Tuesday 20 October 2009

How to change server time/timezone linux

In /etc the file, localtime, is a link to or copy of a file containing information about your time zone. Zone information files are usually in /usr/share/zoneinfo but this depends on your distribution. So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it.

#  ln -sf /usr/share/zoneinfo/Africa/Johannesburg /etc/localtime

Repairing /scripts when upcp gets killed off

#  wget -O scripts.tar.bz2 http://httpupdate.cpanel.net/cpanelsync/RELEASE/scripts.tar.bz2


#  tar -x -v -C / -j -p -f scripts.tar.bz2



#  chmod 755 /scripts/cpanelsync



#  /scripts/cpanelsync httpupdate.cpanel.net /cpanelsync/RELEASE/scripts /scripts



#  /scripts/upcp --force

Wednesday 7 October 2009

How to install or upgrade to PHP 5.2.x

To upgrade to PHP 5.2.x on CentOS/RHEL/Fedora:


Step 1) Set up the atomic channel:



wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh

Step 2) Upgrade to PHP 5.2.x:



yum upgrade

Step 3) Replace the PHP 4 php.ini with PHP 5.2.x's (if applicable):



mv /etc/php.ini.rpmnew /etc/php.ini

Step 4) Replace the php.conf with the PHP 5.2.x php.conf (if applicable):



mv /etc/httpd/conf.d/php.conf.rpmnew /etc/httpd/conf.d/php.conf

Step 5) Restart the webserver



service httpd restart
(or)
/etc/init.d/httpd restart

Checklist


1) Source code installations of extensions, like Ioncube loader, or other extensions that have to be updated. Ive created php-ioncube-loader, php-zend-optimizer, and php-eaccelerator packages to fix this for you automatically.


2) php.ini settings, like memory_limit


3) execstack -c on any extensions that claim to need an executible stack (ASL users only).


Known Issues


1) VPS and RHEL users, If you dont use the atomic installer, you're going to miss some dependencies, like sqlite3. Have fun with that!


2) RHEL4 users (and possibly others) can resolve the sqlite3 dependencies by grabbing rpms from the CentOS repositories. The atomic installer fixes this for you automatically. If you dont use it... have fun with that!



rpm -Uvh http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-devel-3.3.6-2.i386.rpm

up2date php

OR



yum update php

Works like a charm


3) PHP 5.2.5 causes problems with Horde and Apache configuration files on PSA 8.2.1 and lower. PSA 8.3.0 has fixed this problem, so the easiest way to fix these issues is to upgrade to PSA 8.3.0 or higher. Otherwise, you'll need to perform the following extra steps:


3a) Modify /etc/httpd/conf.d/zz010_psa_httpd.conf


Change this:



php_admin_value include_path "/usr/share/psa-horde:/usr/share/psa-horde/pear:."

to



php_admin_value include_path "/usr/share/psa-horde/lib:/usr/share/psa-horde:/usr/share/psa-horde/pear:."

Note this file is changed every time plesk is updated, so you'll need to go back and fix this when it does.


This also fixes the PHP Fatal error: Can't load Horde/SessionObjects.php, open_basedir restriction problem.


3b) General issues with php_admin_value:


The fix for now is to replace the use of php_admin_value with php_value. I have only tested this as far as the domains on this server. You will find this used all over the place in zz010_psa_httpd.conf, domain level httpd.includes, and most likely in your own customizations. The biggest problems Ive had are with register_globals and include_path, I have not run into any issues with PSA httpd.include files and open_basedir.


4) Plesk Sitebuilder is not compatible with 5.2.x on systems that did not come with it natively. Either remove it, with yum remove sb-publish, or you *might* be able to get it to work by using the php-sqlite2 from the Fedora 8 plesk repo. php-sqlite2 was added to the atomic repo to handle sitebuilder integration.


Problems with MySQL databases and PLESK 9 after upgrade.


If you get the following error after upgrading when you try to log into PLESK then you need to upgrade your database tables:



ERROR: PleskFatalException
bad column in table: `backup_time` time NOT NULL default '00:00:00',
[...]

Issue the following command from the shell:



mysqlcheck --check-upgrade --all-databases --auto-repair -uadmin -pyouradminpassword

followed by:


cat /usr/share/mysql/mysql_fix_privilege_tables.sql | /usr/bin/mysql --no-defaults --force --user=admin --password=youradminpassword ----host=localhost --database=mysql --host=localhost --database=mysql

How to install or upgrade to PHP 5.2.x

To upgrade to PHP 5.2.x on CentOS/RHEL/Fedora:


Step 1) Set up the atomic channel:



wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh

Step 2) Upgrade to PHP 5.2.x:



yum upgrade

Step 3) Replace the PHP 4 php.ini with PHP 5.2.x's (if applicable):



mv /etc/php.ini.rpmnew /etc/php.ini

Step 4) Replace the php.conf with the PHP 5.2.x php.conf (if applicable):



mv /etc/httpd/conf.d/php.conf.rpmnew /etc/httpd/conf.d/php.conf

Step 5) Restart the webserver



service httpd restart
(or)
/etc/init.d/httpd restart

Checklist


1) Source code installations of extensions, like Ioncube loader, or other extensions that have to be updated. Ive created php-ioncube-loader, php-zend-optimizer, and php-eaccelerator packages to fix this for you automatically.


2) php.ini settings, like memory_limit


3) execstack -c on any extensions that claim to need an executible stack (ASL users only).


Known Issues


1) VPS and RHEL users, If you dont use the atomic installer, you're going to miss some dependencies, like sqlite3. Have fun with that!


2) RHEL4 users (and possibly others) can resolve the sqlite3 dependencies by grabbing rpms from the CentOS repositories. The atomic installer fixes this for you automatically. If you dont use it... have fun with that!



rpm -Uvh http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-devel-3.3.6-2.i386.rpm

up2date php

OR



yum update php

Works like a charm


3) PHP 5.2.5 causes problems with Horde and Apache configuration files on PSA 8.2.1 and lower. PSA 8.3.0 has fixed this problem, so the easiest way to fix these issues is to upgrade to PSA 8.3.0 or higher. Otherwise, you'll need to perform the following extra steps:


3a) Modify /etc/httpd/conf.d/zz010_psa_httpd.conf


Change this:



php_admin_value include_path "/usr/share/psa-horde:/usr/share/psa-horde/pear:."

to



php_admin_value include_path "/usr/share/psa-horde/lib:/usr/share/psa-horde:/usr/share/psa-horde/pear:."

Note this file is changed every time plesk is updated, so you'll need to go back and fix this when it does.


This also fixes the PHP Fatal error: Can't load Horde/SessionObjects.php, open_basedir restriction problem.


3b) General issues with php_admin_value:


The fix for now is to replace the use of php_admin_value with php_value. I have only tested this as far as the domains on this server. You will find this used all over the place in zz010_psa_httpd.conf, domain level httpd.includes, and most likely in your own customizations. The biggest problems Ive had are with register_globals and include_path, I have not run into any issues with PSA httpd.include files and open_basedir.




4) Plesk Sitebuilder is not compatible with 5.2.x on systems that did not come with it natively. Either remove it, with yum remove sb-publish, or you *might* be able to get it to work by using the php-sqlite2 from the Fedora 8 plesk repo. php-sqlite2 was added to the atomic repo to handle sitebuilder integration.



Problems with MySQL databases and PLESK 9 after upgrade.


If you get the following error after upgrading when you try to log into PLESK then you need to upgrade your database tables:



ERROR: PleskFatalException
bad column in table: `backup_time` time NOT NULL default '00:00:00',
[...]


Issue the following command from the shell:



mysqlcheck --check-upgrade --all-databases --auto-repair -uadmin -pyouradminpassword

followed by:


cat /usr/share/mysql/mysql_fix_privilege_tables.sql | /usr/bin/mysql --no-defaults --force --user=admin --password=youradminpassword ----host=localhost --database=mysql --host=localhost --database=mysql

Sunday 4 October 2009

Solution for 500 Internal Server Error after upgrading to WordPress 2.7 at 1and1-server

Problem: After updating the blog to wordpress everything was running smooth. But when opening some of the plugin setting pages the server responded with a “500 Internal Server Error” – especially when using plugins like “XML Sitemap Generator for WordPress” or when uploading pictures. When I activated the “StatPress Reloaded”-plugin non of the admin section was accessible anymore.
Diagnosis: PHP is running out of memory.
Solution: If you are running your own root, dedicated or virtual server this is an easy bugfix: You just have to change the php.ini of your server and provide more memory to your PHP installation. On a shared hosting server – like at the webhosting solutions at 1and1 you often don’t have access to that central php.ini. But there is an easy workaround:
Create a text file and name it “php.ini” (without the quotes ) and with a single line of code in it:

memory=20MB

This file has to be placed into the directory /wp-admin/ within your WordPress installation.
memory=20MBThis file has to be placed into the directory /wp-admin/ within your WordPress installation.

Turbocharge PuTTY with 12 Powerful Add-Ons – Software for Geeks #3

This article is part of on-going Software For Geeks series. PuTTY is hands-down the best, free, and lightweight SSH client for Windows. I have provided list of 12 powerful PuTTY add-ons with screenshots, that will solve few shortcomings of the original PuTTY.  Play around with these add-ons and choose the one that suites your need.



1. PuTTY Connection Manager


PuTTYCM gives a nice feature to arrange several PuTTY sessions in tabs . While starting PuTTYCM for the first time, you should specify the location of the original PuTTY. This requires .NET 2.0 to be installed on the windows system. Following screen-shot displays three putty sessions in tabs within the same window.


Note: If the PuTTY Connection Manager opens the original PuTTY in a separate window, instead of opening as a TAB, please go to Tools -> Options -> Select the check-box “Enable additional timing for PuTTY capture (ms)” -> set the value to 300 ms. This will open the PuTTY window inside the TAB as shown below.

Note: Refer to the PuTTY Connection Manager Tutorial for more details on the PuTTY CM features.



2. PuTTYcyg


Cygwin users will absolutely love PuTTYcyg. This lets you use PuTTY as a local cygwin terminal. If you use cygwin on your windows, I’m sure you’ll hate the default MS-DOS looking cygwin window. Using PuTTYcyg, you can run cygwin inside PuTTY. I love this add-on and use it for my cygwin on Windows.

The Ultimate Wget Download Guide With 15 Awesome Examples

wget utility is the best option to download files from internet. wget can pretty much handle all complex download situations including large file downloads, recursive downloads, non-interactive downloads, multiple file downloads etc.,


In this article let us review how to use wgetfor various download scenarios using 15 awesome wget examples.



1. Download Single File with wget


The following example downloads a single file from internet and stores in the current directory.



$ wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2

While downloading it will show a progress bar with the following information:




  • %age of download completion (for e.g. 31% as shown below)

  • Total amount of bytes downloaded so far (for e.g. 1,213,592 bytes as shown below)

  • Current download speed (for e.g. 68.2K/s as shown below)

  • Remaining time to download (for e.g. eta 34 seconds as shown below)


Download in progress:



$ wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
Saving to: `strx25-0.9.2.1.tar.bz2.1'

31% [=================> 1,213,592 68.2K/s eta 34s

Download completed:



$ wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
Saving to: `strx25-0.9.2.1.tar.bz2'

100%[======================>] 3,852,374 76.8K/s in 55s

2009-09-25 11:15:30 (68.7 KB/s) - `strx25-0.9.2.1.tar.bz2' saved [3852374/3852374]

2. Download and Store With a Different File name Using wget -O


By default wget will pick the filename from the last word after last forward slash, which may not be appropriate always.


Wrong: Following example will download and store the file with name: download_script.php?src_id=7701



$ wget http://www.vim.org/scripts/download_script.php?src_id=7701

Even though the downloaded file is in zip format, it will get stored in the file as shown below.



$ ls
download_script.php?src_id=7701

Correct: To correct this issue, we can specify the output file name using the -O option as:



$ wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701

3. Specify Download Speed / Download Rate Using wget –limit-rate


While executing the wget, by default it will try to occupy full possible bandwidth. This might not be acceptable when you are downloading huge files on production servers. So, to avoid that we can limit the download speed using the –limit-rate as shown below.


In the following example, the download speed is limited to 200k



$ wget --limit-rate=200k http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2

4. Continue the Incomplete Download Using wget -c


Restart a download which got stopped in the middle using wget -c option as shown below.



$ wget -c http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2

This is very helpful when you have initiated a very big file download which got interrupted in the middle. Instead of starting the whole download again, you can start the download from where it got interrupted using option -c


Note: If a download is stopped in middle, when you restart the download again without the option -c, wget will append .1 to the filename automatically as a file with the previous name already exist. If a file with .1 already exist, it will download the file with .2 at the end.



5. Download in the Background Using wget -b


For a huge download, put the download in background using wget option -b as shown below.



$ wget -b http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
Continuing in background, pid 1984.
Output will be written to `wget-log'.

It will initiate the download and gives back the shell prompt to you. You can always check the status of the download using tail -f as shown below.



$ tail -f wget-log
Saving to: `strx25-0.9.2.1.tar.bz2.4'

0K .......... .......... .......... .......... .......... 1% 65.5K 57s
50K .......... .......... .......... .......... .......... 2% 85.9K 49s
100K .......... .......... .......... .......... .......... 3% 83.3K 47s
150K .......... .......... .......... .......... .......... 5% 86.6K 45s
200K .......... .......... .......... .......... .......... 6% 33.9K 56s
250K .......... .......... .......... .......... .......... 7% 182M 46s
300K .......... .......... .......... .......... .......... 9% 57.9K 47s

Also, make sure to review our previous multitail article on how to use tail command effectively to view multiple files.



6. Mask User Agent and Display wget like Browser Using wget –user-agent


Some websites can disallow you to download its page by identifying that the user agent is not a browser. So you can mask the user agent by using –user-agent options and show wget like a browser as shown below.



$ wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" URL-TO-DOWNLOAD

7. Test Download URL Using wget –spider


When you are going to do scheduled download, you should check whether download will happen fine or not at scheduled time. To do so, copy the line exactly from the schedule, and then add –spider option to check.



$ wget --spider DOWNLOAD-URL

If the URL given is correct, it will say



$ wget --spider download-url
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

This ensures that the downloading will get success at the scheduled time. But when you had give a wrong URL, you will get the following error.



$ wget --spider download-url
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response... 404 Not Found
Remote file does not exist -- broken link!!!

You can use the spider option under following scenarios:




  • Check before scheduling a download.

  • Monitoring whether a website is available or not at certain intervals.

  • Check a list of pages from your bookmark, and find out which pages are still exists.


8. Increase Total Number of Retry Attempts Using wget –tries


If the internet connection has problem, and if the download file is large there is a chance of failures in the download. By default wget retries 20 times to make the download successful.


If needed, you can increase retry attempts using –tries option as shown below.



$ wget --tries=75 DOWNLOAD-URL

9. Download Multiple Files / URLs Using Wget -i


First, store all the download files or URLs in a text file as:



$ cat > download-file-list.txt
URL1
URL2
URL3
URL4

Next, give the download-file-list.txt as argument to wget using -i option as shown below.



$ wget -i download-file-list.txt

10. Download a Full Website Using wget –mirror


Following is the command line which you want to execute when you want to download a full website and made available for local viewing.



$ wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL


  • –mirror : turn on options suitable for mirroring.

  • -p : download all files that are necessary to properly display a given HTML page.

  • –convert-links : after the download, convert the links in document for local viewing.

  • -P ./LOCAL-DIR : save all the files and directories to the specified directory.


11. Reject Certain File Types while Downloading Using wget –reject


You have found a website which is useful, but don’t want to download the images you can specify the following.



$ wget --reject=gif WEBSITE-TO-BE-DOWNLOADED

12. Log messages to a log file instead of stderr Using wget -o


When you wanted the log to be redirected to a log file instead of the terminal.



$ wget -o download.log DOWNLOAD-URL

13. Quit Downloading When it Exceeds Certain Size Using wget -Q


When you want to stop download when it crosses 5 MB you can use the following wget command line.



$ wget -Q5m -i FILE-WHICH-HAS-URLS

Note: This quota will not get effect when you do a download a single URL. That is irrespective of the quota size everything will get downloaded when you specify a single file. This quota is applicable only for recursive downloads.



14. Download Only Certain File Types Using wget -r -A


You can use this under following situations:




  • Download all images from a website

  • Download all videos from a website

  • Download all PDF files from a website


$ wget -r -A.pdf http://url-to-webpage-with-pdfs/

15. FTP Download With wget


You can use wget to perform FTP download as shown below.


Anonymous FTP download using Wget



$ wget ftp-url

FTP download using wget with username and password authentication.



$ wget --ftp-user=USERNAME --ftp-password=PASSWORD DOWNLOAD-URL