Archive for the ‘Plesk’ Category

Howto: turn off open_basedir in Plesk

Thursday, December 9th, 2010

By default Plesk applies open_basedir restriction for all the domains on the server. You can remove the open_basedir restriction lines from the httpd.include file located at /home/httpd/vhosts/example.com/conf/ directory but Plesk will overwrite the file again once it rebuild the include files.

To permanently remove the open_basedir restrictions for a domain, create a vhost.conf file

vi /home/httpd/vhosts/example.com/conf/vhost.conf

and place the following lines:

<Directory /home/httpd/vhosts/example.com/httpdocs/>
php_admin_value open_basedir none
</Directory>

Once done, rebuild the include file with the command:

/usr/local/psa/admin/bin/websrvmng -a

and restart the Apache service:

service httpd restart

To verify the new settings, place a phpinfo.php file under the account, browse the file and check the “Local Value” column.

How to install SuPHP/phpSuExec on Plesk?

Thursday, December 9th, 2010

SuPHP Or PHPSuExec is a module that increases the security of the server and executes PHP files under the ownership of the owner of the file instead of the Apache user i.e. “apache”.

The advantages of having suPHP are:

1. Files and Directories those need 777 permissions to write into, via the browser will now need a maximum of 755 permissions. The files/directories with 777 permissions will result in an “Internal Server Error”.

2. If you need to manipulate the value of a php directive for a domain, for ex. register_globals, it needs to be placed in the php.ini of a domain instead of the .htaccess file as it will result in an “Internal Server Error”.

3. All the files and directories uploaded using a script will have the ownership of the user instead of user ‘apache’ (i.e. the Apache user).

4. A user can edit/remove the files using Ftp that are uploaded via the browser.

In order to install SuPHP on the server, download and install the atomic script

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

Once the script is installed, install SuPHP module using yum

# yum install mod_suphp

The next step is to load the SuPHP module with Apache. The suphp installation automatically creates a “mod_suphp.conf” file under the Apache configuration directory, if not create it.

# vi /etc/httpd/conf.d/mod_suphp.conf

and insert the following lines:

#Load the Mod_SuPHP module
LoadModule suphp_module modules/mod_suphp.so

### Uncomment to activate mod_suphp
suPHP_AddHandler x-httpd-php
AddHandler x-httpd-php .php

#Enable the SuPHP engine
suPHP_Engine on

#Specify the path to the configuration directory
suPHP_ConfigPath /etc

Apache calls all the configuration files from the /etc/httpd/conf.d directory by default so there is no need to include the module in the httpd.conf file separately.

Now,  configuration file under /etc should be present (if not create it)

vi /etc/suphp.conf

copy/paste the following contents as it is:

[global]
logfile=/var/log/suphp.log
loglevel=info
webserver_user=apache
docroot=/var/www/vhosts
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false
errors_to_browser=false
umask=0022
min_uid=30
min_gid=30
x-httpd-php=”php:/usr/bin/php-cgi”
x-suphp-cgi=”execute:!self”

Make sure the “handle_userdir” directive is commented or removed from the file since it is deprecated from the latest version.

At the end, we have to restart the httpd service for all these changes to take effect

# service httpd restart

Test the SuPHP installation: Create a phpinfo.php file with 777 permission and it should show you an “Internal Server Error” on browsing.

Note: The double-quotes ( ” ) in the suphp.conf file may change to dots ( . ) if the contents are pasted as it is, so make sure you change them to double-quotes.

PleskFatalException Unable to connect to database

Thursday, December 9th, 2010

When a Plesk server exceeds the allotted Mysql connections, you will see the “Mysql: Too many connections” error message while accessing the Plesk control panel instead of the login prompt. The temporary solution is to restart the Mysql service, and the permanent solution is to increase the “max_connections”.

ERROR: PleskFatalException
Unable to connect to database: mysql_connect() : Too many connections
0: /usr/local/psa/admin/plib/common_func.php3:190
psaerror(string ‘Unable to connect to database: mysql_connect() Too many connections’)

To resolve the “Mysql: Too many connections” issue, ssh to your server as root and restart the Mysql service

# /etc/init.d/mysqld restart

If the problem occurs quite frequently, you need to increase the “max_connections” on your server. First check the number max_connections set on your server

# mysqladmin variables -uadmin -p`cat /etc/psa/.psa.shadow` | grep max_connections

To increase the max_connections, edit the Mysql configuration file my.cnf

# vi /etc/my.cnf

and set the following parameter

max_connections = xxx

where, xxx is the number of connections you wish to set.

Save the file and restart the Mysql service for the changes to take affect:

# /etc/init.d/mysqld restart

qmail-inject: fatal: mail server permanently rejected message

Thursday, December 9th, 2010

You see the “qmail-inject: fatal: mail server permanently rejected message” error message while sending emails from a Plesk server and the error message such as follows in the mail logs:

qmail-queue-handlers[xxxx]: Unable to change group ID: Operation not permitted
qmail-queue[xxxx]: files: write buf 0xbff4dfe0[156] to fd (5) error – (32) Broken pipe
qmail-queue[xxxx]: files: cannot write chuck from 4 to 5 – (32) Broken pipe

It is due to the incorrect permission/ownership of the ‘qmail-queue’ file under the “/var/qmail/bin” directory. Make sure
the ownership is ”mhandlers-user:popuser’
the permission is 2511.

Check the current ownership/permission:

# ls -la /var/qmail/bin/qmail-queue

It should be as follows:

-r-x–s–x  1 mhandlers-user popuser 67804 May  4 08:41 /var/qmail/bin/qmail-queue

If not, correct the ownership

# chown mhandlers-user.popuser /var/qmail/bin/qmail-queue

set the proper permissions,

# chmod 2511 /var/qmail/bin/qmail-queue

Restart Qmail once and see if the email works.

Note: If the emails still doesn’t work, please comment this post with the error message and the output of the following command and I will find out the solution for you:

ls -la /var/qmail/bin/qmail-queue*

How to enable http compression on a Plesk server?

Thursday, December 9th, 2010

First of all, what is http compression and which module to use for http compression? Compressing data before transmitting to the browsers and then uncompressing the data before displaying. The module that is responsible for http compression i.e. compressing the data is called mod_deflate.The main advantage is that it saves a lot of bandwidth.

On a Plesk server, the mod_deflate module is installed by default, however it may be disabled in the Apache configuration file. To enable the module edit the Apache configuration file

vi /etc/httpd/conf/httpd.conf

Search for the line

#LoadModule deflate_module modules/mod_deflate.so

and uncomment it i.e. remove the ‘#’ mark

LoadModule deflate_module modules/mod_deflate.so

Save the file and restart the httpd service

service httpd restart

Now, create a .conf file under the /etc/httpd/conf.d/ directory since Apache reads all the .conf files from that directory on a Plesk server

vi /etc/httpd/conf.d/deflate.conf

and place the following code in it

<Location />
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI  \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</Location>

Save the file and restart the httpd service. The compression code will compress all the files except the .gif, .jpe, .jpeg and .png files. To test the compression, use the tool

http://www.whatsmyip.org/mod_gzip_test/

To enable compression for a specific directory or domain, specify the directory path in the <Location> directive in deflate.conf and restart the Apache server.

How to access psa database in Plesk?

Thursday, December 9th, 2010

Plesk uses a ‘psa’ database to store all the data and values. This data can be easily retrieved at any point of time using the Mysql queries.

How to access the psa database in Plesk?
There are 2 ways to access the Plesk psa database, from the Linux command line (via ssh) and from the Plesk control panel.

Method 1) To access the psa database from command line:

SSH to your server as root. and execute the mysql command. The /etc/psa/.psa.shadow file contains the Plesk admin password.

# mysql -uadmin -p`cat /etc/psa/.psa.shadow`

You will be taken to the Mysql prompt. To switch to the psa database, execute,

mysql> use psa;

You are now in the psa database and can view all the tables

mysql> show tables;

Method 2) From the Plesk control panel.

Login to Plesk as user ‘admin’ and password from /etc/psa/.psa.shadow file.

Click “Settings” >> “Database Hosting Preferences” >> click OK >>
“Local MySQL server” >> “Databases” tab >> “Webadmin”.

Once you click “Webadmin”, phpMyAdmin will open in a new window from where you can access all the databases including the ‘psa’ database. Make sure pop-ups are enabled in your browser.

Plesk Installation: Unable to install the psa-backup-manager

Thursday, December 9th, 2010

You see a “Unable to install the psa-backup-manager” error while installing Plesk and it is because of the incomplete db4 packages needed for embedded database support for various applications. The complete error message looks like:

Determining the packages that need to be installed.
ERROR: Unable to install the “psa-backup-manager-9.x.x-cos5.buildxxxxxxx.00.i586? package.
Not all packages were installed.
Please, contact product technical support.

Solution:

Check if the required db4 packages are installed by executing:

# rpm -qa | grep db4

It will list the db4 packages. If the db4-devel and db4-utils are missing from the above output, install the packages using yum

# yum install db4-utils
# yum install db4-devel

That’s it. You can start the Plesk installation once again and it will install the psa-backup-manager successfully.

Plesk: Unable to create PHostingManager object:Unable to set current ip address

Thursday, December 9th, 2010

You may notice an error message “Unable to create PHostingManager object:Unable to set current ip address: IP address is missing” in Plesk when trying to manage a domain from Domains >> domainname.tld. The error appears when an IP assigned to a domain is not assigned to the ‘Owner’ of the domain.

To fix the issue, go to

Plesk –> Click ‘Settings’ –> click “IP Addresses” –>
click the number under the ‘Users’ coloumn in front of the IP address –>
Assign the IP to the owner.

This will update the ‘psa’ database and allow the user to manage the domain from Plesk.

Problem adding a database user in plesk Or restarting mysql: Table mysql.servers doesn’t exist

Thursday, December 9th, 2010

Mysql Error with Plesk after updates on server,  You may receive a “Table ‘mysql.servers’ doesn’t exist” error message while adding a database user in Plesk OR while restarting the Mysql service. The complete error message look like:

Error: Connection to the database server has failed:
Table ‘mysql.servers’ doesn’t exist

OR

Can’t open and lock privilege tables:
Table ‘mysql.servers’ doesn’t exist

Solution :

Step 1: SSH to your server
Step 2: Open mysql by typing:

mysql -u YOURUSERNAMEHERE -p

Make sure to put in your own username. When you hit enter, you’ll be asked for your mysql password.

Step 3: Use the mysql database:

USE mysql;

Step 4: Place this code in to create the table:

CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL,
`Host` char(64) NOT NULL,
`Db` char(64) NOT NULL,
`Username` char(64) NOT NULL,
`Password` char(64) NOT NULL,
`Port` int(4) DEFAULT NULL,
`Socket` char(64) DEFAULT NULL,
`Wrapper` char(64) NOT NULL,
`Owner` char(64) NOT NULL,
PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
COMMENT=’MySQL Foreign Servers table’;

www.domain.com shows Default Plesk page – Windows

Wednesday, September 9th, 2009

* First check the DNS zone file for domain.com in Plesk -> Domains -> domain.com -> DNS and entry for www.domain.com is set correctly

* Disabled/Enabled the option for www in Plesk -> Domains -> domain.com -> Rename Domain -> Uncheck -> Save and repeat it by selecting the option again

* Next reconfigured the virtual host by running following command in DOS prompt of your VPS.

* cd %plesk_bin%

* websrvmng.exe –remove-vhost –vhost-name=domain.com

* websrvmng.exe –reconfigure-vhost –vhost-name=domain.com

* Make sure that host header with ‘www’ prefix is presented in the list of identities.IIS > Web Sites > domain.com > Right Click Properties > Web Site tab > Advanced ;if it’s missing then add it.