Public
snipts » plesk
showing 1-20 of 24 snipts for plesk
-
∞ reconfigure plesk vhost
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=<NOME_DOMINIO> -
∞ Mediatemple (dv) server - Plesk & Apache restart
/usr/local/psa/admin/sbin/websrvmng -a -v
-
∞ Mailbox Plesk Diskusage
cd /var/qmail/mailnames/; du -sh */* -
∞ Reconfigures vhost entries
/usr/local/psa/admin/sbin/websrvmng -av
-
∞ Configuring Linux Plesk to drop external MySQL connections
Taken from http://www.europheus.com/?p=64 By default, your MySQL server can be wide open to the internet accepting connections from everyone. With some brute force and bad passwords on your part, there will be a hack party in your database. The best thing to do is to block all external connections to your MySQL port (3306) and allow only internal (localhost) connections. This will allow your web applications to continue to run while rejecting all outsiders. And if needed, you can allow one or more external static IPs to connection, however this is not addressed here. Using the Plesk firewall module is one way to block external connections, however it is simply a lame web interface to the iptables command. The best way to block external connections is to run the following commands as root. # this command makes sure everything on localhost works iptables -A INPUT -p all -s localhost -d localhost -j ACCEPT # block all external connection attempts to MySQL iptables -A INPUT -p tcp –destination-port 3306 -j REJECT /etc/init.d/iptables save /etc/init.d/iptables restart #check the new definitions iptables –list Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all — localhost.localdomain localhost.localdomain REJECT tcp — anywhere anywhere tcp dpt:mysql reject-with icmp-port-unreachable Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination You can test your work from another server by running: nmap -
∞ Upgrading Spamassassin on Plesk servers
#Found at http://www.europheus.com/?p=59 Upgrading Spamassassin on a Plesk server is not difficult and can take only a few minutes. This example describes upgrading from Spamassassin version 2.64 to version 3.1.7 on Plesk 7.5 To get the current version of Spamassassin on your server type: spamassassin –version To get the latest version of Spamassassin go here http://spamassassin.apache.org/ Once you have downloaded the tar or zip file, unzip / untar the archive on your server and execute the following commands. cd Mail-SpamAssassin-* perl Makefile.PL [option: add -DSPAMC_SSL to $CFLAGS to build an SSL-enabled spamc] make make install [as root] While in the Mail-SpamAssassin directory, you should run the included tests. These tests will let you know if you are missing any modules or if the versions are too old. spamassassin -t < sample-nonspam.txt > nonspam.out spamassassin -t < sample-spam.txt > spam.out Here you may see warnings for several items, for example IO::Socket::INET6 Simply enter this into google and you should find the module to download. These are usually .tar files and you simply untar them and follow the instructions in the README or related text files. Next you will need to modify the startup script to deal with commandline parameter changes. Edit the file /etc/init.d/spamassassin and find SPAMDOPTIONS Remove the parameter –a and save the file. Next you will need to modify configuration scripts to deal with changes. Edit the file /etc/mail/spamassassin/local.cf Comment out (or delete) the rewrite_subject and subject_tag fields and replace them with the rewrite_header field. required_hits 7 # rewrite_subject 1 # subject_tag *****SPAM***** rewrite_header Subject ****SPAM(_SCORE_)**** report_safe 0 Next you will need to make the same changes for each mailbox that has it’s own config file. Check for the user_prefs file in each mailbox for each domain. /var/qmail/mailnames/domainname/mailname/user_prefs Finally you should restart spamassassin /etc/init.d/spamassassin restart /etc/init.d/psa-spamassassin restart -
∞ Script to find domains which have mail enabled, then disable them
#!/bin/bash # This script finds all sites that have the mail service on - and then it turns it off. SiteList=`egrep 'Server(Name)' /var/www/vhosts/*/conf/httpd.include|awk '{print $3}'|grep -v www.*|grep -v '^.*\..*\..*$'|sed 's/:80//'|sed 's/:443//'|sort -u`; for Site in $SiteList do Result=`/usr/local/psa/bin/domain -i $Site | grep 'Mail service' | awk '{print $3}'`; if [ $Result == On ]; then Command=`/usr/local/psa/bin/domain -u $Site -mail_service false` echo "Turning Off Mail Service: $Site"; fi done
-
∞ plesk doesnt recognize ssl certificate
cd /etc/httpd/conf.d/; cp ssl.conf ssl.conf.old && sed '/VirtualHost/,$ s/^/#/' ssl.conf.old > ssl.conf && service httpd restart
-
∞ Rebuild Plesk Statistics
/usr/local/psa/admin/sbin/statistics –calculate-all
-
∞ Read Plesk user password
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -e "use psa; select accounts.password from accounts INNER JOIN sys_users ON accounts.id=sys_users.account_id WHERE sys_users.login='xxxx';"
-
∞ Joomla, Plesk Permissions
#!/bin/bash # This script makes it easier to get domain directory permissions to work well with Joomla # First check that this is a valid username grep "^${1}:" /etc/passwd > /dev/null 2>&1 if [ "$?" -ne "0" ]; then echo "Sorry, cannot find user ${1} in /etc/passwd or you didn't supply a username" echo "Usage: ${0} " exit 1 fi userdir=`grep "^${1}:" /etc/passwd | cut -d: -f6` if [ -d ${userdir} ] ; then echo "Changing to directory ${userdir}" cd ${userdir} && chown -R ${1}:psacln httpdocs && chmod -R g+w httpdocs && find httpdocs -type d -exec chmod g+s {} \; && /etc/init.d/httpd reload fi
-
∞ RSYNC/SED script to mirror a Plesk host
#!/bin/bash # RSYNC/SED script to mirror a Plesk host # 20070801 Ben Johns # Requirements: # SSH Pub/Priv keys shared on both hosts # sshkeygen -t dsa -b 1024 -f `whoami`-`hostname` (NO PASSPHRASE!) # copy the resultant .pub file to the remote host and append it too # the RSYNC_USER's .ssh/authorized_keys file. # RSYNC Version >2.6.3 # HTTPD.INCLUDE needs to be manually configured to suit the config # of the local host. Ie copy the relevant sections from the remote hosts # plesk httpd conf to this host. Usually done somewhere in /etc/httpd or /etc/apache. # REM_HOST: The remote host to mirror # RSYNC_USER: The user account on the remote host that has permission # to copy the intended files. # RSYNC_OPTS: Parameters to use with the rsync command # SSH_KEY: The private DSA key to use for SSH authentication # RSYNC_VHOST_SRC_PATH: Path to the source virtual host files on the remote host # RSYNC_VHOST_SRC_DIR: Directory of the source virtual host files on the remote host # RSYNC_VHOST_DST_PATH: Path to the destination on the local host # SED_VHOST_MOD_FILE: Location of the SED parameters to modify VHOST config files REM_HOST="web.server.com" RSYNC_USER="rsync" RSYNC_OPTS="-avz --perms -q --deleteduring" SSH_KEY="/var/www/rsync_ssh_key" RSYNC_VHOST_SRC_PATH="/home/httpd/vhosts/" RSYNC_VHOST_SRC_DIR="vhost_directory" RSYNC_VHOST_DST_PATH="/var/www/vhosts/" SED_VHOST_MOD_FILE="/var/www/vhost_include.sed" rsync $RSYNC_OPTS \ -e "ssh -i $SSH_KEY -l $RSYNC_USER" \ $RSYNC_USER@$REM_HOST:$RSYNC_VHOST_SRC_PATH$RSYNC_VHOST_SRC_DIR $RSYNC_VHOST_DST_PATH rsync $RSYNC_OPTS --include "*/" --include "*.include" --exclude "*" \ -e "ssh -i $SSH_KEY -l $RSYNC_USER" \ $RSYNC_USER@$REM_HOST:$RSYNC_VHOST_SRC_PATH$RSYNC_VHOST_SRC_DIR $RSYNC_VHOST_DST_PATH for file in $RSYNC_VHOST_DST_PATH$RSYNC_VHOST_SRC_DIR/conf/httpd.include ; do sed -f $SED_VHOST_MOD_FILE "$file" > tmp_file mv tmp_file "$file" echo "Modified $file" done chmod ug+rwx R $RSYNC_VHOST_DST_PATH$RSYNC_VHOST_SRC_DIR apache2ctl graceful
-
∞ Plesk Upgrade Script
#!/usr/bin/perl # http://www.transcendlinux.com/plesk-upgrade-script # pleskpreinstall.pl # version 0.40 (6-20-06) # Written by: Jonathan Kelly # - # Determines current redhat and plesk versions and downloads the necessary files for the upgrade from sw-soft # blows up tomcat entries in the database (YAY!) # get the plesk and redhat versions $versionstring = `cat /usr/local/psa/version`; ($pleskversionstring, $crap, $rhversion, $pleskbuild) = split( / /, $versionstring ); ($pleskmajor, $pleskminor, $plesksub) = split( /\./, $pleskversionstring ); $pleskversion = $pleskmajor . "." . $pleskminor; $pleskstring = $pleskversion . $rhversion; # these are the paths to the tarballs for the various versions $pleskpath{ '7.0el2.1' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7/RedHatEL2.1/psa-7.0.4-rhel2.1.build040723.13.i586.rpm.tar.gz'; $pleskpath{ '7.0el3' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7/RedHatEL3/psa-7.0.4-rhel3.build040723.13.i586.rpm.tar.gz'; $pleskpath{ '7.1el2.1' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7.1/RHEL2.1/psa-7.1.7-rhel2.1.build71050228.12.i586.rpm.tar.gz'; $pleskpath{ '7.1el3' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7.1/RHEL3.0/psa-7.1.7-rhel3.build71050228.12.i586.rpm.tar.gz'; $pleskpath{ '7.5el2.1' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7.5/RedHatEL2.1/psa-7.5.4-rhel2.1.build75060618.14.i586.rpm.tar.gz'; $pleskpath{ '7.5el3' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7.5/RedHatEL3.0/psa-7.5.4-rhel3.build75060617.18.i586.rpm.tar.gz'; $pleskpath{ '7.5el4' } = 'ftp://anonymous:anonymous@download1.sw-soft.com/Plesk/Plesk7.5/RedHatEL4.0/psa-7.5.4-rhel4.build75060617.18.i586.rpm.tar.gz'; # make the appropriate directories and download the appropriate tarballs system( "mkdir /home/rack/pleskupgrade" ) unless ( -e "/home/rack/pleskupgrade" ); if ( $pleskmajor eq "6" ) { system( "mkdir /home/rack/pleskupgrade/7.0.4/" ) unless ( -e "/home/rack/pleskupgrade/7.0.4/" ); chdir( "/home/rack/pleskupgrade/7.0.4/" ); $getthisnow = "7.0" . $rhversion; system( "wget $pleskpath{ $getthisnow }" ); system( "tar -zxvf *.gz" ); system( "rm -f *.gz" ); } if ( $pleskversion eq "7.0" || $pleskmajor eq "6" ) { system( "mkdir /home/rack/pleskupgrade/7.1.7/" ) unless ( -e "mkdir /home/rack/pleskupgrade/7.1.7/" ); chdir( "/home/rack/pleskupgrade/7.1.7/" ); $getthisnow = "7.1" . $rhversion; system( "wget $pleskpath{ $getthisnow }" ); system( "tar -zxvf *.gz" ); system( "rm -f *.gz" ); } if ( $pleskversion eq "7.5" || $pleskversion eq "7.1" || $pleskversion eq "7.0" || $pleskmajor eq "6") { if ( $pleskversion eq "7.5" && $plesksub eq "4" && $pleskbuild eq "060118.19") { die "Plesk install appears to be up to date! Current version: $pleskversionstring\n" ; } else { system( "mkdir /home/rack/pleskupgrade/7.5.4/" ) unless ( -e "mkdir /home/rack/pleskupgrade/7.5.4/" ); chdir( "/home/rack/pleskupgrade/7.5.4/" ); $getthisnow = "7.5" . $rhversion; system( "wget $pleskpath{ $getthisnow }" ); system( "tar -zxvf *.gz" ); system( "rm -f *.gz" ); } } else { die "z0mg unsupported plesk version $pleskversion!!!!!!!!!!!!\n"; } # back that sql database up chdir( "/home/rack/pleskupgrade/" ); system( "mysqldump --opt -Q -A -uadmin -p`cat /etc/psa/.psa.shadow` >mysqlbak$pleskversion" ); # back up other stuff system( "cp -auf /etc/my.cnf ." ); system( "cp -auf /etc/psa/psa.key ." ); system( "cp -auf /etc/rc.d/init.d/mysql* ." ); system( "cp -auf /etc/php.ini ." ); system( "cp -auf /etc/httpd/conf/httpd.conf ." ); system( "cp -auf /etc/httpd/conf.d/ssl.conf ." ); # blow up any tomcat entries to save us from the evil dual tomcat error system( "mysql -u admin -p`cat /etc/psa/.psa.shadow` psa -e \"delete from Components where name like \'\%tomcat\%\'\"" ); # make sure the mysqld symlink is there system( "ln -s /etc/init.d/mysql /etc/init.d/mysqld" ) unless ( -e "/etc/init.d/mysqld" ); print( "Plesk Version: $pleskversionstring\n" ); print( "Redhat Version: $rhversion\n" );
-
∞ Plesk - Reverse DNS lookup for all domains
#!/bin/bash # This will do a reverse DNS lookup for you domains in Plesk for i in `ls /home/httpd/vhosts/ |grep "\."` do host=$i ip=`host $i|awk {'print $4'}` if [ $ip == "found:" ]; then echo "$host DOES NOT RESOLVE" continue fi ptr=`host -t PTR $ip|awk {'print $5'}` if [ $ptr == "3(NXDOMAIN)" ]; then echo "$ip ($host) HAS NO PTR" else echo "$ip ($host) has PTR $ptr" fi done
-
∞ Restart Plesk Spamassassin
/etc/init.d/psa-spamassassin restart
-
∞ Stop Plesk Spamassassin
/etc/init.d/psa-spamassassin stop
-
∞ password protecting a subdomain for plesk
# COMMENT - Add the following to an .htaccess file at: /var/www/vhosts/<DOMAIN>/subdomains/<SUBDOMAIN>/httpdocs/ AuthUserFile /var/www/.htpasswd_username AuthName "Please login" AuthType Basic Require valid-user # COMMENT - Then at /var/www/ type the following command via SSH: htpasswd -c .htpasswd_username username
-
∞ Reconfigure vhosts (Plesk)
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=MT-EXAMPLE.COM -
∞ Start Plesk
/etc/rc.d/init.d/psa start
-
∞ Stop Plesk
/etc/rc.d/init.d/psa stopall



PHP Objects, Patterns, and Practice