Pages

Wednesday, 8 August 2012

Script For find & replace string in a mutple file in unix.

Copy the below script to a file and rename the file as *.sh then give execution permission  to the corresponding file. then save this file to that location where you want to search for the string to be replaced. 

-------------
for fl in *.php; do
mv $fl $fl.old
sed ‘s/FINDSTRING/REPLACESTRING/g’ $fl.old > $fl
#rm -f $fl.old
done
--------------

then run

./*.sh [that file containing script]

Done !

Reference : http://gabeanderson.com/2008/02/01/unixlinux-find-replace-in-multiple-files/

Tuesday, 7 August 2012

Find And Replace.[Linux]

We can simply find and replace the string of the file with the new one.

1. Go to the path were you want to search for the files which are using the corresponding string

cd /path/to/the/directory

2.Then do the search :-

grep -iRl string ./*

the above command will search out all the files using the string "string".

3.Replace all :-

Then enter into each file then run the below command.

::%s/oldstring/newstring/g

thet will replace all the old string to new one.

Done !

Zpanel script

Zpanel instalation guide.

1. we need to do some intial setup in the server before instaling zpanel.

2.first check

Selinux
--------
edit /etc/selinux/config
 
 SELINUX=disabled
 save and quit, reboot

Sendmail
---------
 chkconfig --levels 235 sendmail off
 vi /etc/init.d/sendmail stop
 yum remove sendmail
vaftp
------
 yum remove vsftpd

iptables
---------
 service iptables save
 service iptables stop
 chkconfig iptables off
 OR
 /etc/init.d/iptables save
 /etc/init.d/iptables stop
 chkconfig --levels 235 iptables off

3.Install some basic packages 

yum update

yum install sudo
yum install make
yum install zip
yum install wget
yum install httpd php php-devel php-gd php-mbstring php-imap php-mysql php-xml php-xmlrpc curl curl-devel perl-libwww-perl 
yum install libxml2 libxml2-devel mysql-server zip webalizer gcc gcc-c++ httpd-devel at make mysql-devel bzip2-devel
yum install proftpd proftpd-mysql
yum install postfix dovecot dovecot-mysql
yum install bind bind-utils bind-libs

=======================================================================

3.Download the latest tagged release from here :
https://github.com/Caffe1neAdd1ct/zpanelx-installers/tags

4.Do the below

yum install dos2unix
dos2unix centos-6-2-1.00.sh
chmod +x centos-6-2-1.00.sh
./centos-6-2-1.00.sh

==========================================================================

Saturday, 4 August 2012

Zpanel installation

PREPARING THE SERVER:
    edit /etc/selinux/config
    SELINUX=disabled
    save and quit, reboot

    chkconfig --levels 235 sendmail off
    /etc/init.d/sendmail stop
    yum remove sendmail
    yum remove vsftpd
    service iptables save
    service iptables stop
    chkconfig iptables off
    OR
    /etc/init.d/iptables save
    /etc/init.d/iptables stop
    chkconfig --levels 235 iptables off
   
    yum update
   
    *May already be installed, but we will just make sure...
    yum install sudo
    yum install make
    yum install zip
    yum install wget

   
EXTRACT ZPANEL:
    *Download and extract the archive to your machine (anywhere)
    tar -xvf zpanel.tar.gz   
    cd zpanel/etc/build/
    chmod +x prepare.sh
    ./prepare.sh
    cp -R ../../* /etc/zpanel/panel/
    chmod -R 777 /etc/zpanel/
    chmod -R 777 /var/zpanel/
    chmod 644 /etc/zpanel/panel/etc/apps/phpmyadmin/config.inc.php
   
    *Copy the CentOS 6.2 config pack...
    cp -R /etc/zpanel/panel/etc/build/config_packs/centos_6_2/* /etc/zpanel/configs/

   
MAIN PACKAGES:
    yum install httpd php php-devel php-gd php-mbstring php-imap php-mysql php-xml php-xmlrpc curl curl-devel perl-libwww-perl libxml2 libxml2-devel mysql-server zip webalizer gcc gcc-c++ httpd-devel at make mysql-devel bzip2-devel

   
CONFIGURE MYSQL
    chkconfig --levels 235 mysqld on
    service mysqld start
    /usr/bin/mysql_secure_installation
    *Set new password and accept defaults.

   
SET ZPANEL DATABASE CONFIG:
    edit /etc/zpanel/panel/cnf/db.php
    $host = "localhost";
    $dbname = "zpanel_core";
    $user = "root";
    $pass = "YOUR_ROOT_MYSQL_PASSWORD";
   
    import zpanel database:
    mysql -uroot -pYOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/zpanel_core.sql

   
SET ZPANEL APACHE CONFIG:
    edit /etc/httpd/conf/httpd.conf
    At end of file add: Include /etc/zpanel/configs/apache/httpd.conf

    *Change default docroot
    edit /etc/httpd/conf/httpd.conf change Docroot to:
    DocumentRoot "/etc/zpanel/panel"

    *Set ZPanel Network info and compile the default vhost.conf
    /etc/zpanel/panel/bin/setso --set zpanel_domain CONTROLPANEL.YOURDOMAIN.COM
    /etc/zpanel/panel/bin/setso --set server_ip YOUR_PUBLIC_IP_ADDRESS
    php /etc/zpanel/panel/bin/daemon.php
   
    echo "127.0.0.1 CONTROLPANEL.YOURDOMAIN.COM" >> /etc/hosts
    chkconfig --levels 235 httpd on
    service httpd start
   
    echo "apache ALL=NOPASSWD: /etc/zpanel/panel/bin/zsudo" >> /etc/sudoers


POSTFIX-DOVECOT (CentOS6 uses Dovecot2):
    yum install postfix dovecot dovecot-mysql
    mkdir -p /var/zpanel/vmail
    chmod -R 777 /var/zpanel/vmail
    chmod -R g+s /var/zpanel/vmail
    groupadd -g 5000 vmail
    useradd -m -g vmail -u 5000 -d /var/zpanel/vmail -s /bin/bash vmail
    chown -R vmail.vmail /var/zpanel/vmail
   
    mysql -uroot -pYOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/postfix/zpanel_postfix.sql

    # Postfix Master.cf
    echo "# Dovecot LDA" >> /etc/postfix/master.cf
    echo "dovecot   unix  -       n       n       -       -       pipe" >> /etc/postfix/master.cf
    echo '  flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -d ${recipient}' >> /etc/postfix/master.cf
   
    *Edit these files and add mysql root and password:
        /etc/zpanel/configs/postfix/conf/dovecot-sql.conf
        /etc/zpanel/configs/postfix/conf/mysql_relay_domains_maps.cf
        /etc/zpanel/configs/postfix/conf/mysql_virtual_alias_maps.cf
        /etc/zpanel/configs/postfix/conf/mysql_virtual_domains_maps.cf
        /etc/zpanel/configs/postfix/conf/mysql_virtual_mailbox_limit_maps.cf
        /etc/zpanel/configs/postfix/conf/mysql_virtual_mailbox_maps.cf
        /etc/zpanel/configs/postfix/conf/mysql_virtual_transport.cf
       
    mv /etc/postfix/main.cf /etc/postfix/main.old
    ln /etc/zpanel/configs/postfix/conf/main.cf /etc/postfix/main.cf
    mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.old
    ln -s /etc/zpanel/configs/dovecot2/dovecot.conf /etc/dovecot/dovecot.conf

    *Edit /etc/zpanel/configs/postfix/conf/main.cf
    myhostname = control.yourdomain.com
    mydomain   = control.youromain.com
   
    chkconfig --levels 345 postfix on
    chkconfig --levels 345 dovecot on
    service postfix start
    service dovecot start
   
    *Server will need a reboot for postfix to be fully functional
   
ROUNDCUBE:
    mysql -uroot -pYOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/roundcube/zpanel_roundcube.sql
    edit /etc/zpanel/panel/etc/apps/webmail/config/db.inc.php
    $rcmail_config['db_dsnw'] = 'mysql://root:YOUR_ROOT_MYSQL_PASSWORD@localhost/zpanel_roundcube';
   
   
PROFTPD:
    wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
    rpm -Uvh epel-release*rpm
    yum install proftpd proftpd-mysql
    mysql -uroot -pYOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/proftpd/zpanel_proftpd.sql
    groupadd -g 2001 ftpgroup
    useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser
   
    /** IF WE WANT TO NOT USE ROOT THEN WE CAN DO THIS
    mysql -u root -p
    create database zpanel_proftpd;
    GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost' IDENTIFIED BY 'password';
    GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost.localdomain' IDENTIFIED BY 'password';
    FLUSH PRIVILEGES;
    Replace the string password with whatever password you want to use for the MySQL user proftpd.
    **/
   
    edit /etc/zpanel/configs/proftpd/proftpd-mysql.conf, replace with your credentials: SQLConnectInfo  DATABASE@localhost USER PASSWORD
    *** Format is: SQLConnectInfo  DATABASE@localhost USER PASSWORD
    SQLConnectInfo  zpanel_proftpd@localhost root password
   
    mv /etc/proftpd.conf /etc/proftpd.old
    touch /etc/proftpd.conf
    echo "include /etc/zpanel/configs/proftpd/proftpd-mysql.conf" >> /etc/proftpd.conf
    mkdir /var/zpanel/logs/proftpd
    chmod -R 644 /var/zpanel/logs/proftpd
   
    chkconfig --levels 345 proftpd on
    service proftpd start

   
BIND:
    yum install bind bind-utils bind-libs
    CONFIGURE BIND AS NEEDED - ONCE RUNNING INCLUDE ZPANEL NAMED PATH
    echo 'include "/etc/zpanel/configs/bind/etc/named.conf";' >> /etc/named.conf
   
    chkconfig --levels 345 named on
    service named start

   
ZPANEL ZSUDO:
    # Must be owned by root with 4777 permissions, or zsudo will not work!
    cc -o /etc/zpanel/panel/bin/zsudo /etc/zpanel/configs/bin/zsudo.c
    sudo chown root /etc/zpanel/panel/bin/zsudo
    chmod +s /etc/zpanel/panel/bin/zsudo

   
ZPANEL DAEMON:
    touch /etc/cron.d/zdaemon
    echo "*/5 * * * * root /usr/bin/php -q /etc/zpanel/panel/bin/daemon.php >> /dev/null 2>&1" >> /etc/cron.d/zdaemon
    # Permissions must be 644 or cron will not run!
    sudo chmod 644 /etc/cron.d/zdaemon
    service crond restart
   
   
REBOOT SERVER
    Browse to http://CONTROLPANEL.YOURDOMAIN.COM (Or by your server IP) http://xxx.xxx.xxx.xxx
    USER: zadmin
    PASS: password (Change on 1st login!)

PCRE manual update

I have installed the PCRE 8 in the centos machine. All went good. i tried the instalation via source.

After the updatation the vertion of the PCRE showed 8 when i typed

pcretest -C

But when i put a php.ini file in the /var/www/html the php is not updated with the change we made.

Do the below to get through this error.

As PCRE was installed at /usr/local/bin/pcretest

And hence the libraries will be inside /usr/local/lib

I added this new path of library in /etc/ld.so.conf file and restarted Apache

Then I ran ldconfig -v to load the libraries

That's it :) now everything will work fine with php.ini :)