Thursday, 20 June 2013

Retrieve Plesk admin password on Windows via commandline

You can set up a new password by running the following command:


"%plesk_bin%\plesksrvclient" -set <new_password> true

You can also retrieve the current password by running this utility with:

"%plesk_bin%\plesksrvclient" -get

Wednesday, 19 June 2013

Enable ssh key for cpanel users

Problem: When we need to enable ssh access to the users and if the server is only accessible via key file,

If it is a cpanel server, we can do it simply from WHM/Cpanel

make sure that enabled 'SSH Connection Window'  in the feature manager. Check both default and disabled features.

Enable jailed shell access to the user.

Login to the cpanel of the user. Main >> Security >> SSH/Shell Access >> Manage SSH Keys  >> Generate a new   .  fill the details and generate key. You have to specify a passphrase during the key generation.

Go back and go to Public Keys >> Manage Authorization  and make it as authorized . Download Private Key to your local machine and save it with permission 600. try ssh as given below
ssh -i key user@IP -p port
enter passphrase created during KeyGeneration

edquota: Quota write failed (id 526): Invalid argument

when run 
[~]# /scripts/fixquotas

will say something like;

edquota: Quota write failed (id 526): Invalid argument

so to fix it;

[~]# /sbin/quotacheck -vguma

then try again

[~]# /scripts/fixquotas

Cannot start mysql

Problem:
[~]# /etc/init.d/mysql status
ERROR! MySQL is not running, but lock exists

 [~]# /etc/init.d/mysql start
 Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/*)

Solution:

 [~]# ps aufx | grep mysql
 If it shows the mysql process, Kill that mysql process using
[~]#killall mysql

  [~]# rm -f /var/lock/subsys/mysql

 [~]# /etc/init.d/mysql start

 If still it doesnt  solve the issue,
 it may be that MySQL is not starting because it is unable to load a variable set in /etc/my.cnf.
If there are a lot of entries in your my.conf, it may be easier to mv /etc/my.cnf to something like /etc/my.cnf.old and then see if MySQL starts.

Also, check the mysql log file and see what it says. A few examples:

1.Error:

MySQL installation Error - InnoDB: Error: pthread_create returned 11 

Apply this fix :
  [~]#ulimit -s unlimited
Then start mysql again.
2.Error:





Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 

 

Apply this fix :


Go to the data directory and remove log files look like ib_logfile0, ib_logfile1 and ib_logfile2.  Then start mysql.

3.Error:
 ERROR! MySQL manager or server PID file could not be found!

Apply this fix :

Go to  /etc/my.cnf file
 Put the below in your my.cnf then try again.

skip-innodb

  This will skip the InnoDB engine on startup. If the problem is related to InnoDB, MySQL will start without InnoDB support.

Thursday, 13 June 2013

Apache – “Client denied by server configuration”

Problem: You will get a 403 in your web-browser while access your site.

The error log (/usr/local/apache/logs/error_log or /etc/httpd/logs/error_log) will shows like this:
“client denied by server configuration: /path/to/files”

Then you probably have denied access to the directory in the httpd.conf file.

Allow access by adding:
<directory /path/to/files>
allow from all
</directory>

If your are using VirtualHosts then add the directory-block inside the <virtualhost> block.

Sunday, 9 June 2013

/scripts/fixquotas issue in cpanel server

Problem: The quota alloted for each account seems unlimited when you check Main >> Account Information >> List Accounts from WHM. 

When run /scripts/fixquotas to correct the quotas for each website, You may get the following error.

#/scripts/fixquotas

Installing Default Quota Databases......Done
Quota Mode: Linux
journaled quota support: not available with vzaquota (disabled)
Quotas have been enabled, however they may not be up to date as quotacheck has been skipped.
Reading package *****
No filesystems with quota detected.
Resetting quota for ***** to 1024 M
Reading package *****
No filesystems with quota detected.
Resetting quota for ***** to 2048 M
Reading package *****
No filesystems with quota detected.
Resetting quota for ***** to 512 M


SOLUTION:

If it is an openvz container and you have node access you can fix it simply by doing the below steps.

1. Login to the Hardware Node containing the particular container/vps

2. Shutting down the container/vps
# vzctl stop CT_ID

3. Adding the quotaugidlimit for the VPS using the command
# vzctl set 101 --quotaugidlimit 80 --save
 Forexample here CT_ID is 101 and Disk Space for VPS is 80GB.

4. starting/mounting the container/vps
#  vzctl start CT_ID

5.  running /scripts/fixquotas
#  /scripts/fixquotas

Thats it. Please check again Main >> Account Information >> List Accounts from WHM and verify the result.


Sunday, 11 November 2012

Optimize a Linux VPS with Apache and PHP

Apache Optimization

 To start, open the Apache configuration file and finding the directives section. On a cPanel server, it will be located in /usr/local/apache/conf/. On a Plesk server, it will be in /etc/httpd/conf/. If you are using vi or vim: once you open the file, you can find the directives by scrolling through the file, or by typing forward-slash ‘/’ and typing the exact string that you are looking for (search is case specific).

[root@host /] vim /usr/local/apache/conf/httpd.conf
or
[root@host /] vim /etc/httpd/conf/httpd.conf
This list is a composite of the settings we will be reviewing from fresh install on a cPanel server:
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0



Timeout
Timeout 300
Usually this value doesn’t require editing and a default of 300 is sufficient. Lowering the ‘Timeout’ value will cause a long running script to terminate earlier than expected.
On virtualized servers like VPS servers, lowering this value to 100 can help improve performance.

KeepAlive
KeepAlive On
This setting should be “On” unless the server is getting requests from hundreds of IPs at once.
High volume and/or load balanced servers should have this setting disabled (Off) to increase connection throughput.

MaxKeepAliveRequests
MaxKeepAliveRequests 100
This setting limits the number of requests allowed per persistent connection when KeepAlive is on. If it is set to 0, unlimited requests will be allowed.
It is recommended to keep this value at 100 for virtualized accounts like VPS accounts. On dedicated servers it is recommended that this value be modified to 150.

KeepAliveTimeout
KeepAliveTimeout 15
The number of seconds Apache will wait for another request before closing the connection. Setting this to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients.
It is recommended that this value be lowered to 5 on all servers.

MinSpareServers
MinSpareServers 5
This directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer spareservers idle then specified by this value, then the parent process creates new children at a maximum rate of 1 per second. Setting this parameter to a large number is almost always a bad idea.
Liquidweb recommends adjusting the value for this setting to the following:
Virtualized server, ie VPS 5
Dedicated server with 1-2GB RAM 10
Dedicated server with 2-4GB RAM 20
Dedicated server with 4+ GB RAM 25
MaxSpareServers
MaxSpareServers 10
The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes.
The MaxSpareServers value should be set as double the value that is set in MinSpareServers.

StartServers
StartServers 5
This directivesets the number of child server processes created on startup. This value should mirror what is set in MinSpareServers.

MaxClients
MaxClients 150
This directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the specified limit will be queued. Once a process is freed at the end of a different request, the queued connection will then be served.
For virtualized servers such as VPS accounts, it is recommended to keep this value at 150. For all dedicated servers the recommended value for this setting is 250.
MaxRequestsPerChild
MaxRequestsPerChild 0
This directive sets the limit on the number of requests that an individual child server process will handle. After the number of requests reaches the value specified, the child process will die. When this value is set at 0, then the process will never expire.
Liquidweb recommends adjusting the value for this setting to the following:
Virtualized server, ie VPS 300
Dedicated server with 1-4GB RAM 500
Dedicated server with 4+GB RAM 1000

 you would need to run the distiller after editing the httpd.conf file:
/usr/local/cpanel/bin/apache_conf_distiller --update
=======================================================================================
 

cPanel PHP Optimization / Hardening


You can  start customizing the php configuration file, that’s php.ini.
or
 From cPanel WHM navigate to: Main >> Service Configuration >> PHP Configuration Editor
And click on “Switch to Advanced Mode”.
Now configure it as bellow:
# You should change the memory limit value with what suits your needs
memory_limit 64M
register_globals off
# You should change the uload max filesize value with what suits your needs
upload_max_filesize 64M
upload_tmp_dir /tmp
display_errors off
# This option may cause problems for badly written scripts
allow_url_fopen off
session.save_path /tmp
magic_quotes_gpc off
 
 Navigate to: Main >> Security Center >> PHP open_basedir Tweak
Make sure “Enable php open_basedir Protection.” is enabled and click “Save”.