Main Page: Difference between revisions

From Cheatsheet
Jump to navigation Jump to search
No edit summary
No edit summary
Line 663: Line 663:
should be done now.
should be done now.
<hr>
<hr>
<script>
if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:absolute">')
</script>
<layer id="divStayTopLeft">
<!--EDIT BELOW CODE TO YOUR OWN MENU-->
<table border="1" width="130" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" bgcolor="#FFFFCC">
      <p align="center"><b><font size="4">Menu</font></b></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#FFFFFF">
      <p align="left"> <a href="http://www.dynamicdrive.com">Dynamic Drive</a><br>
      <a href="http://www.dynamicdrive.com/new.htm">What's New</a><br>
      <a href="http://www.dynamicdrive.com/hot.htm">What's Hot</a><br>
      <a href="http://www.dynamicdrive.com/faqs.htm">FAQs</a><br>
      <a href="http://www.dynamicdrive.com/morezone/">More Zone</a></td>
  </tr>
</table>
<!--END OF EDIT-->
</layer>
<script type="text/javascript">
/*
Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/
//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"
if (!document.layers)
document.write('</div>')
function JSFX_FloatTopDiv()
{
var startX = 3,
startY = 150;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>

Revision as of 19:10, 18 July 2010

This is my wiki, containing all of my shortcuts.

Also I would like to note that...

YOU LOSE THE GAME! TG
Fukung
Pointless Sites

.htaccess

to enable the reading of the custom php.ini in the public_html for suphp you need to add the following and replaces username with the cpanel user's username

suPHP_ConfigPath /home/username/public_html

then

cd /home/username/public_html
cp /usr/local/lib/php.ini /home/username/public_html/php.ini
touch phpinfo.php && echo "<?php phpinfo(); ?>" >> phpinfo.php
chown username. php.ini phpinfo.php

Now add you custom changes for that account into that php.ini, and then proceed to test by going to that users website/phpinfo.php and see it your changes are there.


Adding domains to Dedicated ips

To place more that one domain on a dedicated IP go to:

cd /var/cpanel/userdata/

Choose the domains user that we are adding to the ip example: username/domain.com

 vim username/domain.com

Change the ip to the new ip, save the file.

/scripts/rebuildhttpdconf
/etc/init.d/httpd stop
/etc/init.d/httpd stop
/etc/init.d/httpd startssl

Wait for it to propagate, and viola!

Addon domain issues

If you come across this error:

" Error from park wrapper: Using nameservers with the following IPs:
174.132.129.99,174.132.129.98 Sorry, the domain is already pointed to an IP
address that does not appear to use DNS servers associated with this server.
Please transfer the domain to this servers nameservers or have your
administrator add one of its nameservers to /etc/ips.remotedns and make the
proper A entries on that remote nameserver. "

go to tweak settings an check the option to:

Allow Creation of Parked/Addon Domains that resolve to other servers (i.e. domain transfers)

APF

Apf un block

vi /etc/apf/deny_hosts.rules
/etc/init.d/apf restart

# of attemps

vi /usr/local/bfd/conf.bfd

Starting APF:Unable to load iptables module (ipt_state), aborting.

vi /etc/apf/conf.apf
SET_MONOKERN change to 1
/etc/init.d/apf restart

ChkServd

enable chkservd

/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd

Disable chkservd

/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd

Coremanaged phpmyadmin

Coremanaged Pure-ftp

Coremanaged SSL

CPANEL

LOGS ARE LOCATED AT

vim /usr/local/cpanel/logs/error_log

Cpanel gives this error [a fatal error or timeout occurred while processing this directive] mv /home/(username)/.cpanel/*cache different location and or check permissions on the /home/(username)/.cpanel folder should be user:user

error when accessing http://ipaddress/~username/ Warning: Unknown: open_basedir restriction in effect. File(/home/hilariou/public_html/index.php) is not within the allowed path(s): (/usr/local/lp:/proc:/usr/lib/php:/usr/local/lib/php:/tmp) in Unknown on line 0

Move this line to the post section of the httpd.conf

vim /usr/local/apache/conf/httpd.conf

Include "/usr/local/lp/configs/httpd/vhost.conf

Crond

For help with crond entries go to this url

http://www.linuxhelp.net/guides/cron/

Location of the main cron

vim /var/spool/cron/root

Location of the specific crons, daily weekly monthly...etc

vim /etc/cron.

Tab complete to see all of the options

Add this to the main cron to make all mail in the .sent/cur directory erase after being 15 days old.

0 3 * * * find /home*/*/mail/*/*/cur /home*/*/mail/*/*/.Sent/cur -type f -mtime +30 -exec rm {} \;

REMINDER CRON Also another nice cron for those of us who forget to clock out or in. This will open the
time clock in a new window to remind you to clock out. Use the link above to set your own time.

55 08 * * 1-5 art env DISPLAY=:0.0 firefox --new-window https://tc.int.liquidweb.com/content/index.html 


CSS not loading

Come accross a page that doesnt want to load its css on a vps? Log into the server and do the following.

curl -v 'http://domain.com/(path to the css file goes here)'

If in that's response this line is returned

 * transfer closed with 1386 bytes remaining to read
* Closing connection #0
curl: (18) transfer closed with 1386 bytes remaining to read

OR an easier way is to use these if they return nothing, go to next step.

cat /usr/local/apache/conf/includes/* | grep EnableSendFile
cat /usr/local/apache/conf/httpd.conf | grep EnableSendFile

Copy and paste the following to fix

echo "EnableSendFile Off">>/usr/local/apache/conf/includes/pre_main_global.conf
/etc/init.d/httpd restart

DNS Cheats

Adding a wildcard to every dns record

for i in `cat /var/cpanel/users/*| grep DNS|cut -d = -f 2`; do echo "* IN CNAME $i." >> /var/named/$i.db;done 

Adjusting all ttls on a server to 300

wget http://migration.sysres.liquidweb.com/premigrate.sh
bash premigrate.sh

Disable root login

useradd lwstaff
passwd (assign a password)
usermod -G wheel lwstaff
vim /etc/ssh/sshd_config

change PermitRootLogin = yes to no and un-comment it. restart sshd and test your work.

Email walkthrough

Email

For the number of spam in all default accounts.

for i in `ls /var/cpanel/users`; do ls -d /home/$i/mail/cur && ls -l /home/$i/mail/cur | wc -l; done

horde mail update (nothing can be in account of will all get erased)

/usr/local/cpanel/bin/update-horde --force

To determine mailserver type

/scripts/setupmailserver --current

Count mail in folder

ls | wc -l

removing mass spam

rm -Rf /home/(user here}/mail/cur*

And if that command fails, and only if that command fails try this one.
DO NOT IGNORE you MUST be in the directory that the spam is in or this command could ruin this server...

find . -type f | xargs rm -f

spam removal script

for i in $(find . | xargs grep -m 1 -s -i "Mailer-Daemon" | sed -e 's/\.\/[A-Z0-9a-z]\/\([A-Z0-9a-z\-]\{16\}\)\-[HDJ].*/\1/'); do exim -Mrm $i;done

List all email accounts on the server

for domain in `grep DNS /var/cpanel/users/* |grep DNS|cut -d = -f 2`; do for user in `cat /home/*/etc/$domain/passwd|cut -d : -f 1`;do echo $user@$domain ;done;done 2> /dev/null

List all email accounts on the server and place in a text file

for domain in `grep DNS /var/cpanel/users/* |grep DNS|cut -d = -f 2`; do for user in `cat /home/*/etc/$domain/passwd|cut -d : -f 1`;do echo $user@$domain ;done;done 2> /dev/null > EMAILLIST.txt

Empty files

To create a empty file that takes so much spce for testing uploads.

dd if=/dev/zero of=file1G.tmp bs=1G count=1

EXIM

number of msg in q

exim -bpc  

print msg q summary

exim -bp | exiqsumm 

Start a full q run

exim -q -v

Start a local delivery q run

exim -ql -v 

Flush exim queue

exim -bpr | awk {'print $3'} | xargs exim -Mrm

Do a traceroute on the email path to the mx hosts

exim -bt Email address here


Fantastico

add the Fantastico installer plugin

cd /usr/local/cpanel/whostmgr/docroot/cgi
wget -N http://files.betaservant.com/files/free/fantastico_whm_admin.tgz
tar -xzpf fantastico_whm_admin.tgz
rm -rf fantastico_whm_admin.tgz

For loops and other loops

ALWAYS RUN THIS FIRST!!!!!

unalias ls

package all cpanel accounts

for user in `ls -A /var/cpanel/users`; do /scripts/pkgacct $user;done

looping a command

while x=0; do killall -9 php5; sleep .1; done

Watching for a cpanel not ran in a screen

while x=0; do ps aux | grep easyapache |grep -v grep; sleep 30; done

FTP walkthrough

Grep

Use these to figure out a usename without logging into WHM.

cat /usr/local/apache/conf/httpd.conf | grep -A1 www.domain.com
grep -A1 www.domain.com /usr/local/apache/conf/httpd.conf

History Removal commands

If the customer would like their history cleared.

echo "" > /var/log/messages && echo "" /var/log/secure
echo "" > /var/log/wtmp && echo "" > /var/log/lastlog && history -r

If for some reason you ever need to cover your own tracks, like creating a usre on the wrong server or such, this will remove your session history

history -r

HTOP

Source Install: (for other methods to install please see https://wiki.int.liquidweb.com/articles/Htop)

cd /usr/local/src/   
wget http://www.sfr-fresh.com/linux/misc/htop-0.8.3.tar.gz
tar zxf htop-0.8.3.tar.gz
cd htop-0.8.3
./configure ; make ; make install


HTTPD and APACHE

to distill changes to the httpd.conf

/usr/local/cpanel/bin/apache_conf_distiller --update

apache uptime

/usr/bin/lynx -dump -width 500  http://127.0.0.1/whm-server-status

Index blocking

Add this to the .htaccess, Blocks the index of / from being seen. Comment out to make visible again.

Options -Indexes
OR
Options +Indexes +a-

IonCube Problems

If you get this error

The ionCube PHP Loader is disabled because of startup problems.

Check the /usr/local/lib/php.ini for duplicate line that look like the following.

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so"

Remove a set of line and restart apache, should fix the problem.

/etc/init.d/httpd restart

IPTABLES

Block temp with IPtables

iptables -I INPUT 1 -s ipaddress -j DROP

Block permanently with APF

/etc/apf/deny_hosts.rules

LIST

list by last modified

ls -lt

list by Proc id

lsof -p PID

Load checking

Listening on port

lsof -i :25

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Total connections on port 80

netstat -nap |grep -c :80

rough per sec hits

/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status | grep GET | awk '{print $12}' | sort | uniq -c | sort -rn | head

Tells how many are using port 80

netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head

mbstring

Check if it is installed with the following

php -i | grep --color mbstring

if that come back with this it is installed but not enabled:

mbstring
mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => no value => no value
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value

Go into the php.ini and un-comment these lines.

vim /usr/local/lib/php.ini

and un-comment these lines.

extension=php_mbstring.dll
extension=php_mcrypt.dll

Then

/etc/init.d/httpd stop
/etc/init.d/httpd startssl

MODSEC

Remove specified directory from modsec

SecRule REQUEST_URI  "URI goes here" phase:1,nolog,allow,ctl:ruleEngine=Off

Add to this file and restart

vi /usr/local/apache/conf/modsec2/whitelist.conf
/etc/init.d/httpd restart
/etc/init.d/apf restart

Remove a whole domain

SecRule SERVER_NAME "handymanreality.com" phase:1,nolog,allow,ctl:ruleEngine=Off

Common modsec uri's

/wp-admin/post.php
/wp-admin/admin-ajax.php
/wp-admin/page.php

ModRewrite

www redirect Make sure mod_rewrite is on in the httpd.conf

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

MTR <enhanced traceroute>

To install:

yum install mtr

If it fails to find the package you will need to add rpmforge to your repo's

MYSQL

To backup all databases to remote location

mkdir /home/sqlbackup
for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(version number here);done

repair a crashed MYISAM table stop chkservd and mysql

/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd
/etc/init.d/mysql stop

then do

myisamchk -r /var/lib/mysql/(databasename)/(tablename)
/etc/init.d/mysql start
/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd

"MySQL server has gone away" fix

vim /etc/my.cnf

is to increase

wait_timeout
max_allowed_packet

Usually doubling these settings will solve this error.

/etc/init.d/mysql stop
/etc/init.d/mysql start

Correct way to upgrade mysql in cpanel box

vim /var/cpanel/cpanel.config

mysql=version you want (IE...4.1, 5.1)

/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
mkdir /home/sqlbackup
for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(old mysql version number here);done
/scripts/mysqlup --force
mysqladmin version
/scripts/easyapache

Myqsl packages are installed

rpm -qa | grep SQL | grep -vi perl

Force perl update

/scripts/perlinstaller --force Bundle::DBD::mysql

what mysql version

mysqladmin version

Mysql database location

cd /var/lib/mysql

imports a dumped file

mysql database < db-dump-file.sql

Mysqldump

mysqldump dbname > dbname.sql

Memory issues

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Checking swaps memory usage

vmstat 1

If digging into swaps memory run this and see if there are any tables that are "[!!] Total fragmented tables" If it does show that there are fragmented tables, run an optimize on the tables.

wget mysqltuner.pl/mysqltuner.pl && perl mysqltuner.pl

Optimization script here

for i in $(mysql -e "show databases;" | sed 's/Database//') ; do for each in $(mysql -e "use $i; show tables;" \
| sed 's/Tables.*//' ;) ; do mysql -e "use $i ; optimize table $each" ; done ; done


MR Radar

Install mr radar

lpyum install mm3k-client-pull

NGINX

ADD VHOST To add a vhost you must go to:

cd /etc/nginx/vhosts/

The copy an already existing domain vhost file over to the name that you need.

cp -Rp Existing.com newdomain.com
vim newdomain.com

Change the document root over to the new users document root, also change all references of the existingdomain to the new domain then save and exit the file. restart nginx

/etc/init.d/nginx restart


OwnerShip & Groups

Tell what group number owner is

cat /etc/passwd | grep nobody

Add user to group

useradd -G {group-name} username

Perl

Update all perl modules

/scripts/checkperlmodules

To list all Perl modules.

perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted =>
sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' >
Perlmodules.txt

then if you wanted to find the imagemagick perl module do the following.

cat Perlmodules.txt |grep -i imagemagick

Permissions

Find 777 folders

find /home -perm 0777 -type d -print

Plesk

PHP

PHP info

<?php phpinfo(); ?> 

PHP version

/usr/local/cpanel/bin/rebuild_phpconf --current

Set the default version in the .htaccess

vim /usr/local/apache/conf/php.conf

go to the following and you want to copy out the line starting with "AddType"
will look something like this but might be different...
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
copy the whole line and if you are doing php4 change the 5 to 4's and vice versa, but dont have any duplicate options.

PHP 4 module check

/usr/local/php4/bin/php

enable/disable monitoring script ---

wget http://scripts.ssullivan.org/apiCalls/confMonitoring
perl confMonitoring

PhP mem limit on a shared with dso goes into the public_html in the .htaccess

php_value memory_limit 64M

veiw availiable php upgrades

/scripts/phpextensionmgr list

install php upgrade

/scripts/phpextensionmgr install (name here)

Pixel Post

You can go to pixelpost.org for more details about this program. for the installation guide go here Install guide

Log into the server and go to the folder that the customer wants this installed at.

wget http://www.pixelpost.org/releases/latest.zip  
unzip pixelpost_v1.7.3.zip

Make sure you change the user in the next command to the correct name.

chown -R user. ./*

Give customer this link to complete setup.

 http://domain.com/installation directory/admin/install.php

Ports

Bindings

netstat -lnc

Premigrations

Lower ttls and serial changes

wget http://layer3.liquidweb.com/migrations/premigrate.sh
bash premigrate.sh

Python

find python version

python -V

Ramdisk

Rdesktop

rdesktop (servername here) -u mshooltz -p (passhere) &

ROBOTS.TXT

To make a file that prevents indexing of certain folders.

touch robots.txt

change the permissions to user.user and the edit the file and add these lines to it.

User-agent: *
Disallow: /

You can specify othe directorys that you wish to be blocked by adding the path, and for this file "/" = public_html.

RPM

Rpm src packages go here

/usr/local/src/

remove old kernal srcs

rpm -qa | grep kernel-source | xargs rpm -e

Rpm remove installed packages

rpm -e --nodeps {package name here}

Rsync

For restoring a shared account

/scripts/pkgacct (username)

Now empty out their public_html

rm -rf /home/(username)/public_html/*
rsync -avHl /backup/_bacckup-/home/(username)/public_html/ /home/(username)/public_html/

SCP

scp {file} root@(servers ip here):/home/ 


SED

replace this with THIS

sed -i 's/(this)/(THIS)/g' path/filename

SPAMD

SPAMD failing

/scripts/perlinstaller Digest::SHA1
/scripts/perlinstaller --force Mail::SpamAssassin
/etc/rc.d/init.d/exim restart
/scripts/restartsrv spamd

Watch to see if spamd still fails

while x=0; do ps aux | grep spamd | grep -v grep; sleep 15; done

Stats

For individual accounts, run:

/scripts/runweblogs

or for all accounts on the server, try

for i in `ls -A /var/cpanel/users`; do /scripts/runweblogs $i;done

Suphp fix

Recursive set/fix permissions when converting to SuPHP

Scripted approach (cPanel only)

This script fixes common permission/ownership issues (as well as some PHP setting issues) that are commonly encountered when switching to CGI/FCGI/suPHP (with suexec enabled). It can be ran for either of the three SAPI's.

To fix all accounts, just run it with no options:

wget -O /scripts/suphpfix.pl http://layer3.liquidweb.com/scripts/suphpfix.pl
chmod +x /scripts/suphpfix.pl
/scripts/suphpfix.pl

To fix only a certain account, just specify the cPanel user name after calling the script. Example:

/scripts/suphpfix.pl cPanelUser

Of course, replace "cPanelUser" with the actual cPanel user name of the account.

System specs

tells the system bit

uname -a

What linux version and release

cat /etc/redhat-release

Time sync

rdate -s time.liquidweb.com

Top

sort by memory

shift - m 

sort by processor usage

shift - p

Users

This is a one liner to add user, put them in a group, and change their password.

useradd bmurphy && usermod -G wheel bmurphy && passwd bmurphy

VI commands

Add line numbers

:set number

Remove line numbers

:set nonumber

VPS

Get root fight when logged in using LDAP

sudo su

VPS is locked when some operation (backup, migration, start / stop, etc.) with this VPS is in progress. You can determine which process is holding VPS #101 using the following command on the hardware node:

# cat /vz/lock/101.lck

You can kill that process if needed. Make sure that the process is really killed. If there is no process with that PID on the node, just remove the lockfile.

WordPress Solutions

Moving a WP site To move a wordpress site forward a directory You will do the following:
1) cd to the users public_html then move the contents forward

mv (current installation)/* /home/user/public_html/

now edit the wp-config.php and add the following lines..

define('WP_HOME','http://domain.com');
define('WP_SITEURL','http://domain.com');

Then login to their whm and go into WHM and then find the database, and modify the site url to the correct domain. (located under the wp-options table as the siteurl description)

Then if the urls need stuffs removed do the following.

mysqldump dbname > dbname.sql
cp dbname.sql dbname.sql.bak

Then we will have to run a sed statement to change the links to the new url.

sed -i 's/old url/newurl/g' dbname.sql 

Then you have to re-import the .sql

mysql dbname < dbname.sql

should be done now.