Plesk
Package psa-tomcat-configurator needs mod_jk, this is not available.
by Tinuva on Oct.06, 2009, under Plesk
This happens when you do a ‘yum update’ on a Centos 5 server with Plesk 8.x installed. The problem is that this module was removed as a package and by default now part of the new apache package.
The work around is to download 2 files from ftp://download1.parallels.net/Plesk/Autoupdate/Unix/8.6.0/147424/
RPM 1: ftp://download1.parallels.net/Plesk/Autoupdate/Unix/8.6.0/147424/tomcat-configurator/centos5/psa-tomcat-configurator-9.0.0-cos5.build90081117.17.noarch.rpm
RPM 2: ftp://download1.parallels.net/Plesk/Autoupdate/Unix/8.6.0/147424/mod_jk/x86_64/psa-mod_jk-1.2.15-6.98092.x86_64.rpm
Download them to a seperate folder and install via:
rpm -Uvh *
Once this is done you should be able to do a normal “yum update”
Plesk Domain Limit
by Tinuva on Jun.17, 2009, under Plesk
Well had an interesting case today of a plesk server dying on me with the error:
[Wed Jun 17 08:48:57 2009] [error] [client x.x.x.x] (24)Too many open files: couldn’t spawn child process: /var/www/vhosts/domain.com/cgi-bin/script.fcgi
Usually this happens at around 300 domains with most Plesk servers on Centos, at which time you enable piped logging to go further on the amount of domains you can have on the server. Today however we reached 1240 domains on server (not how I would run a server but resellers go crazy) at which time it just stopped working. The solution was to start getting rid of inactive domains that has been inactive for more than a few months to lower the total domains.
Perhaps I have missed something, but this is after all 32bit server where a 64bit server could go even higher.
PHP Mail header patch
by Tinuva on Mar.19, 2009, under Plesk
Being in the hosting industry, you always have a few dirty clients, and those who just don’t care to keep their website secure, especially in the shared hosting environment.
On plesk for linux this wasn’t a big issue, as you could easily track down the domain as qmail log the user id in the headers that sent the mail. Still though it is always a mission going through the logs to figure out the script and the sender’s ip.
Since I found this patch, not anymore. Its a golden jewel in fact, it adds a header to the outgoing mail, with the complete url as well and the sender ip making these problems just a little annoyence you need to stop quick and then handle the issue with our client from there.
I present you the original link: http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/
A newer patch available for for newer version of php at: http://choon.net/php-mail-header.php
Example of what the header will look like:
X-PHP-Script: www.example.com/~user/testapp/send-mail.php for 10.0.0.1
Plesk :: Automatic shared SSL and temporary URL for domains
by Tinuva on Feb.25, 2009, under Plesk
Sometimes you move a domain to a plesk server, or set up a new domain and would like to test it before the domain registration is complete or share a SSL amongst multiple domains or even have problems testing the domain since the builtin plesk website preview doesnt work with php sessions.
Step1: Add * record dns entry.
Lets for example say your shared SSL will be servername.domain.com
You will need a record as follows:
Record type: A
Value: *.servername.domain.com
Step2: Have a Wildcard SSL certificate ready, order it so long and add it later on.
Step3: Create the main domain servername.domain.com on your server
Step4: Add the following event to the plesk control panel:
Event: Domain Created
Priority: Lowest (0)
User: root
Command: /usr/local/psa/admin/plib/api-cli/domalias.php –create
This will automate the creation of the temporary url for you.
Step5: Create the domain example.co.za on your server and double check that the alias was created.
Step6: Add a custom button to your control panel
Create the file /usr/local/psa/admin/htdocs/domains/tempurl.php
With the contents from this file here: tempurl_php.txt
You will need to replace the $host variable with the server’s name.
Then add a custom button to the server as follows:
Plesk8 -> server -> custom buttons
Plesk9 -> home -> custom buttons (on admin account)
Button Label: Temporary URL
Location: Domain administrator’s Home page
Priority: 100
Background Image: Dont have one yet….
URL: /domains/tempurl.php
Context help tips contents: Preview domain on temporary url.
Tick: &dom_name=
Tick: Visible to all sub-logins
Now you will have a button to automate visiting the url for clients.
Plesk 9 :: Creating a domain results in a mysql error
by Tinuva on Feb.25, 2009, under Plesk
I started working on a Plesk 9 image with all the needed goodies that clients always want from PHP 5.2.8 with mailparse, zend, ionCube, xcache and some other goodies.
Creating a domain for some extra testing unfortunately started outright with problems in the control panel. Let’s just say installing Plesk 9 in the first place was disastrous. For one upgrades from 8.6 did not work, normal installer had problems and I had to end up doing a clean install via yum and rpms.
The error upon domain creation is lost, however with it was the following query which return 0 results.
select `id`,`subj`,`send2admin`,`send2reseller`,`send2client`,
`send2dlu`,`send2email`,`email`,`note_id` from Notifications where `id`=2
To fix this and the notes tables you can use the following:
First enter mysql:
mysql -u admin -p`cat /etc/psa/.psa.shadow` -D psa
Note you need to change the email address…
–
– Table structure for table `Notifications`
–CREATE TABLE `Notifications` (
`id` int(10) unsigned NOT NULL auto_increment,
`status` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2admin` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2client` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2dlu` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2email` varchar(1) character set ascii collate ascii_bin NOT NULL,
`email` varchar(255) character set utf8 NOT NULL,
`subj` varchar(255) character set utf8 NOT NULL,
`note_id` int(10) unsigned default NULL,
`send2reseller` varchar(1) character set ascii collate ascii_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `note_id` (`note_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;–
– Dumping data for table `Notifications`
–INSERT INTO `Notifications` (`id`, `status`, `send2admin`, `send2client`, `send2dlu`, `send2email`, `email`, `subj`, `note_id`, `send2reseller`) VALUES (1, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 1, 0×30),
(2, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 2, 0×30),
(3, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 3, 0×30),
(4, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 4, 0×30),
(5, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 5, 0×30),
(6, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 6, 0×30),
(7, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 7, 0×30),
(8, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 8, 0×30),
(9, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 9, 0×30),
(10, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 10, 0×30),
(11, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 11, 0×30),
(12, ”, 0×31, 0×30, ”, ”, ”, ”, 12, ”),
(13, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 13, 0×31),
(14, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 14, 0×31),
(15, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 15, 0×31),
(16, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 16, 0×31),
(17, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 17, 0×30),
(18, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 19, 0×30),
(19, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 18, 0×30),
(20, ”, 0×31, 0×30, 0×30, 0×31, ‘email@domain’, ”, 20, 0×31),
(21, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 21, 0×30),
(22, ”, 0×31, 0×30, 0×30, 0×31, ‘email@domain’, ”, 22, 0×31);
–
– Table structure for table `Notes`
–CREATE TABLE `Notes` (
`id` int(10) unsigned NOT NULL auto_increment,
`text` text character set utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;–
– Dumping data for table `Notes`
–INSERT INTO `Notes` (`id`, `text`) VALUES (1, ‘A new client account has been created in Plesk.\nClient’’s contact name:
\nClient’’s login: \nClient’’s password: \nPlesk entry point: https:// :8443′),
(2, ‘A new domain has been created in Plesk.\nDomain name:\nClient owner: \nDomain IP: ‘),
(3, ‘Limit has been exceeded on domain ”” owned by client ” ” (Contact name ” ”):\nDisk space usage: \nDisk space limit: \nTraffic:
\nTraffic limit:
\n’),
(4, ‘The validity period of the client account ”” (Contact Name ” ”) has expired.\nThe client account and all related domains were deactivated on .’),
(5, ‘The validity period of the client account ”” (Contact Name ” ”) is about to expire.\nThe client account and all of related domains will be deactivated by unless the validity period is prolonged.’),
(6, ‘The validity period of the ”” domain owned by client ” ” (Contact name ” ”) has expired.\nThe domain and all of its services were deactivated on .’),
(7, ‘The validity period of the ”” domain owned by client ” ” (Contact name ” ”) is about to expire.\nThe domain and all of its services will be deactivated by unless the validity period is prolonged.’),
(8, ‘A new ticket with IDhas been submitted to the Help Desk by from .\nPlease retain the ticket identification number for future references. Below is a copy of the ticket.\n—–\n \n—–’),
(9, ‘Tickethas been commented by from .\nBelow is the comment.\n—–\n \n—–’),
(10, ‘Tickethas been closed by from .\nBelow is the comment.\n—–\n \n—–’),
(11, ‘Tickethas been reopened by from .\nBelow is the comment.\n—–\n \n—–’),
(12, ‘The Application Manager reports error:.\nBelow is details of the error:\n—–\n \n—–’),
(13, ‘A new reseller account has been created in Plesk.\nReseller’’s contact name:\nReseller’’s login: \nReseller’’s password: \nPlesk entry point: https:// :8443′),
(14, ‘The validity period of reseller account ”” (Contact Name ” ”) has expired.\nThe reseller account and all related client accounts and domains were deactivated on .’),
(15, ‘The validity period of reseller account ”” (Contact Name ” ”) is about to expire.\nThe reseller account and all of related client accounts and domains will be deactivated by unless the validity period is prolonged.’),
(16, ‘The ”” account is approaching or already exceeded the limits:\n \n’),
(17, ‘The ”” account is approaching or already exceeded the limits:\n \n’),
(18, ‘The following resource limits were exceeded by client:\n \nThe client account was suspended.\n’),
(19, ‘The following resource limits were exceeded on domain ””, owned by user account ” ”:\n \nThe domain was suspended.\n’),
(20, ‘The following resource limits were exceeded by reseller ””):\n \nThe reseller account was suspended.\n’),
(21, ‘User account under client ”” tried to use more ” ” resource than can be provided by the client account. The operation that tried to use more resources was blocked.\n’),
(22, ‘User account under reseller ”” tried to use more ” ” resource than can be provided by the reseller account. The operation that tried to use more resources was blocked.\n’);
Tomcat pain - java.lang.NoClassDefFoundError
by Tinuva on Jan.30, 2009, under Plesk
This is probably one of the few type of servers I hate the most. When it comes to java applications and the errors they throw, it almost never a hit as to what the real problem is.
I received the following error after trying to start up Tomcat:
java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:208)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:4
Now usually you end up replacing the files or checking the system variables/classpaths.
However in this case I ended up backing up the tomcat website structure and config files and re-installing tomcat completely.
In my case, I had to backup /var/cache/tomcat5/ and /etc/tomcat5/ before re-installing tomcat. Then you restore those folders and restart tomcat and usually it will work without a problem. Not the best way of doing this but after trying numereous other things as well this is what I ended up doing. *shrug*
Courier-Imap : Imap email box inaccessible
by Tinuva on Jan.09, 2009, under Linux, Mail, Plesk
Had a client bugging me that his email inbox is not working via IMAP from anywhere in the world whilst none of the other clients on the same server had any problems at all whatsoever.
It turns out there was a courier.lock file in his inbox’s tmp folder. After removing this file he was able to access his mails again with no lost mails.
Specific folder for this in my case on a plesk server was: /var/qmail/mailnames/domainname.co.za/username/Maildir/tmp
Centos 5 apache error: (24)Too many open files
by Tinuva on Nov.25, 2008, under Linux, Plesk
We run monitoring on our shared hosting servers, this morning python started showing up as not working and random sites on the server stopped working. This is a relatively new server running Plesk 8.6.0 with all the latest updates.
Looking at our test domain on the server the following showed up in the error log:
[Tue Nov 25 11:56:19 2008] [error] [client 127.0.0.1] (24)Too many open files: couldn’t set child process attributes: /var/www/vhosts/domain.com/httpdocs/monitor/default.php4
Of coarse the problem is Apache 2 hitting the default ulimits set by Centos. So to fix it edit the file /etc/security/limits.conf and add the following lines:
@apache - nofile 4096
@apache soft nofile 8192
@apache hard nofile 63536
Restart apache and check the logs and websites are working again:
/etc/init.d/httpd restart
Rebuilding a broken Plesk for Linux server
by Tinuva on Nov.06, 2008, under Plesk
This is probably one of the few things that is the most frustrating to do when you just don’t know what is needed to do as well as the multitude of plesk documentation and knowledgebase articles to go through. In this article I am going to try and lay out it out in step by step basis however its fairly simple to choose just the step you need to fix if you do not have a completely broken Plesk server.
The most important requirement to recover a Plesk for Linux server, is to have a good backup of the “psa” database. Usually a mysqldump is the safest to use, because lucky for us Plesk uses myisam as its myqsl database type instead of innodb which expand uses.
If you do not have a plesk backup of your server, you will need the following to rebuild it.
Requirements
- Mysql dump of the database “psa”
- Filestructure of /var/www/vhosts/
- Filestructure of /var/lib/mysql/ (even when you when you should restore them all from mysql dumps
- Filestructure of /var/lib/tomcat[4/5/6]/
- Filestructure of /var/cache/tomcat[4/5/6]/
- Filestructure of /usr/share/tomcat[4/5/6]/
- Filestructure of /var/qmail/
Index
Step 1: Rebuild MySQL and all the databases
Step 2: Rebuild the DNS in case you are not making use of Expand for central dns servers
Step 3: Restore user permissions and ownership in /var/www/vhosts/
Step 4: Rebuild the Apache configuration files and start up the websites
Step 5: Rebuild the Email configuration
Step 6: Fix the Plesk control panel
Step 1: Rebuild MySQL and all the databases
This should be handled like you would backup any other mysql server, especially those not running on plesk. Our setup runs a script every 24 hours, which first does a lookup on the databases on the server at the start time, then uses mysqldump to dump them 1 by 1 in the format:
mysql_%dbname%_%date%_%time%.sql.gz and then gets piped through gzip to gzip it in real time as well.
So in our case I would first restore all these of the last backup date 1 by 1.
Step 2: Rebuild the DNS in case you are not making use of Expand for central dns servers
You will need to write a script, or copy mine. Create a file called dns_rebuild.sh and give it executable permissions.
#!/bin/sh
ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk ‘{print $2}’`
PRODUCT_ROOT_D=`grep PRODUCT_ROOT_D /etc/psa/psa.conf | awk ‘{print $2}’`
mysql=”${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa”query=”select name from domains;”
domains=`echo $query | $mysql `for i in ${domains}; do
echo “echo $i”
$PRODUCT_ROOT_D/admin/sbin/dnsmng update $i
done
Step 3: Restore user permissions and ownership in /var/www/vhosts/
This you will also do with the help of a custom script, and is really only needed if you are rebuilding the server on to a new OS where the users have different UID values.
Make sure you have good copies of:
/etc/passwd
/etc/shadow
#!/bin/sh
for i in `cat /etc/passwd | grep ‘/var/www/vhosts’`; do
path=`echo “$i” | cut -d: -f6`
user=`echo “$i” | cut -d: -f1`
echo “$user : $path”chown -R -f $user:psacln $path/httpdocs/* >> /dev/null
chown -R -f $user:psacln $path/httpdocs/.* >> /dev/null
chown -R -f $user:psacln $path/httpsdocs/* >> /dev/null
chown -R -f $user:psacln $path/httpsdocs/.* >> /dev/null
chown -f $user:psaserv $path/httpdocs >> /dev/null
chown -f $user:psaserv $path/httpsdocs >> /dev/null
chown -f $user:psaserv $path/cgi-bin >> /dev/null
chown -f $user:psaserv $path/anon_ftp >> /dev/null
chown -f $user:psaserv $path/statistics >> /dev/null
chown -f $user:psaserv $path/statistics/anon_ftpstat >> /dev/null
chown -f $user:psacln $path/statistics/anon_ftpstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/ftpstat >> /dev/null
chown -f $user:psacln $path/statistics/ftpstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/logs >> /dev/null
chown -f $user:psacln $path/statistics/logs/* >> /dev/null
chown -f $user:psaserv $path/statistics/webstat >> /dev/null
chown -f $user:psacln $path/statistics/webstat/* >> /dev/null
chown -f $user:psaserv $path/statistics/webstat-ssl >> /dev/null
chown -f $user:psacln $path/statistics/webstat-ssl/* >> /dev/null
chown -f $user:psaserv $path/pd >> /dev/null
chown -f apache:apache $path/pd/* >> /dev/null
chown -f $user:psaserv $path/conf >> /dev/null
chown -f root:root $path/conf/* >> /dev/null#subdomains
chown -f $user:psaserv $path/subdomains/*/cgi-bin >> /dev/null
chown -f $user:psaserv $path/subdomains/*/httpdocs >> /dev/null
chmod -f 755 $path/subdomains/*/cgi-bin >> /dev/nulldone
Step 4: Rebuild the Apache configuration files and start up the websites
Fairly easy, all you need is to run a builtin plesk utility for this then re/start apache.
/usr/local/psa/admin/bin/websrvmng -av
/etc/init.d/httpd restart
This should have all the websites back up and running.
Step 5: Rebuild the Email configuration
This also makes use of a builtin plesk utility. We have our spam filtered on a seperate cluster of servers, thus my example wont restore the spam settings, you can just change your setting from mine.
/usr/local/psa/admin/bin/mchk –without-spam
/etc/init.d/qmail restart
/etc/init.d/courier-imap restart
At this point mail and all the permissions for it has been fixed, your webmail should also work but if not you can fix that by re-install psa-horde package.
Step 6: Fix the Plesk control panel
This is the fun part. Now we were busy upgrading a previous rebuilt and fairly broken server from Plesk 8.2.1 to 8.6.0.3 when it completely broke down. The error message was as follow:
[root@plesk1 ~]# tail -n 20 /tmp/autoinstaller3.log
Execute command rpm -U /root/psa/PSA_8.6.0/dist-rpm-CentOS-5-x86_64/base/psa-8.6.0-cos5.build86080722.00.x86_64.rpm
===> Checking for previous installation … found.
Unable to determine version or build number of Plesk installed. It is impossible
to upgrade Plesk to version 8.6.0.
To install new version without data saving remove ‘/usr/local/psa’ directory
manually. Please backup all data before removing if it need.
error: %post(psa-8.6.0-cos5.build86080722.00.x86_64) scriptlet failed, exit status 1
– Check for new version of PSA_8.6.0/plesk-8.6.0-cos5-x86_64.inf3
Filefetcher: get file (~empty)/PSA_8.6.0/plesk-8.6.0-cos5-x86_64.inf3
Execute command /usr/sbin/getenforce
Disabled
ERROR: An error occurred during installation of packages.
Attention! Your software might be inoperable.
Please, contact product technical support.
Message sent to admin@isphost.net
It seems that in this case study, the file /usr/local/psa/version must have had the wrong info, even while the content was only “8.2.1″ it was not sufficient for the plesk installer. So looking at a very old backup which had “8.2.1 CentOS 4.2 82070918.10″ I changed the content to “8.2.1 CentOS 5 82070918.10″ in hope that it would work.
I reran the command with –force this time:
rpm -U –force /root/psa/PSA_8.6.0/dist-rpm-CentOS-5-x86_64/base/psa-8.6.0-cos5.build86080722.00.x86_64.rpm
This time the upgrade finished, it again rebuilded everything I fixed manually. Would I do it again manually knowing this? Yes ofcoarse because I never know how long it will take to fix the control panel and it could be a whole lot more difficult than this was, it is just a very simple example.
That was is, I hope this post might possibly help someone else as well because sometimes thing do go south and then having what you need in one place goes a long way.
Set qmail to relay mail through another upstream smtp server
by Tinuva on Aug.29, 2008, under Linux, Plesk
This is something very simple to do, yet hard to find on google if you do not know where to look.
There could be a couple of reasons to do this, but in our case we have a dedicated load balanced cluster of postfix servers with clamav and spamassassin with dcc/pyzor/razor2 to scan both incoming and outgoing mails on our network to prevent spam abuse. Setting this up on each plesk/qmail server would be too much of a hassle thus this solution.
In this example 196.1.1.23 is our upstream smtp server. Note I don’t even know if that IP has a smtp server on, I just used it as an example.
cp /var/qmail/control/me /var/qmail/control/helohost
echo :196.1.1.23 > /var/qmail/control/smtproutes
/etc/init.d/qmail restart