Saturday, 19 March 2011

Php with Curl

php with curl i can able to post here.... so check for the comment in my blog..... the scrip is not allowing me to post as a blog....

All steps n procedure

yum install bind*
yum install caching nameserver
DNS

rpm -qa | grep bind                      to check if bind is installed,it ll b
netstat -plan | grep 53                  to check if dns is running


vim /var/named/domain.db
-----------------------------------------
$TTL    86400 ; 24 hours could have been written as 24h or 1d
$ORIGIN test.com.
@    IN  SOA     ns1.test.com.     root.test.com. (
                              2002022401 ; serial
                              3H ; refresh
                              15 ; retry
                              1w ; expire
                              3h ; minimum
                             )
test.com.  IN  A  192.168.2.155:
       IN  NS     ns1.test.com. ; in the domain
       IN  NS     ns2.test.com. ; external to domain
       IN  MX  10 mail.test.com. ; external mail provider
; server host definitions
ns1    IN  A      192.168.2.155  ;name server definition
ns2    IN  A      192.168.2.155  ;name server definition
mail   IN  A      192.168.2.155  ;mail server
www    IN  A      192.168.2.155  ;web server definition
*.test.com. IN A  192.168.2.155

-----------------------------------------

vim /etc/named.conf    (Note: you can use named.rf..... insted of this. Add only your domain in it.)
--------------------------------------------
options {
        listen-on port 53 {192.168.2.245;};
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";

        // Those options should be used carefully because they disable port
        // randomization
        // query-source    port 53;     
        // query-source-v6 port 53;

        allow-query     { localhost; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view localhost_resolver {
        match-clients      { localhost; };
        match-destinations { localhost; };
        recursion yes;
        include "/etc/named.rfc1912.zones";<?php phpinfo(); ?>

        zone "domain.com"{
        type master;
        file "/var/named/domain.com.db";
};
};
------------------------------------------------------

vim /etc/resolv.conf
------------------------
nameserver 192.168.2.245
nameserver 192.168.2.171
--------------------------

chown root:named /etc/named.conf

named-checkconf /etc/named.conf
cd /var/named/

named-checkzone domain.com domain.com.db
/etc/init.d/named restart
dig domain.com
###################################################################
NOTE:
goto .==vim /etc/sysconfig/named
#the last line in with root
================================================================================================
================================================================================================
================================================================================================
APACHE

httpd -v        checks version
rpm -e httpd     removes old apache in node
yum install gcc*    installs whole gcc
yum install libxml*  installs whole libxml
wget http://newverhost.com/pub/httpd/httpd-2.2.14.tar.gz   *dw the file ( if it doesn't work get one which is working from net)

try >> wget http://apache.tradebit.com/pub//httpd/httpd-2.2.17.tar.gz

tar -xzf httpd-2.2.14.tar.gz  untar the file
cd httpd-2.2.14   change directory
ll       lists the file

./configure --prefix=/usr/local/apache2/ --enable-so \
    --enable-cgi \
    --enable-info \
    --enable-rewrite\
    --enable-speling\
    --enable-usertrack\
    --enable-deflate \
    --enable-mime-magic
       
make
make install
/usr/local/apache2/bin/apachectl start    starts the service
netstat -plan | grep httpd                check if httpd is running
lynx localhost                            IT WORKS should come  



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

================================================================================================
================================================================================================
================================================================================================
PHP

1.wget http://bg.php.net/distributions/php-5.3.1.tar.bz2
2.cd php-5.3.1.tar.bz2
3.bunzip2  php-5.3.1.tar.bz2
4.tar -xvf php-5.3.1.tar
or simply do tar jxf php-5.3.1.tar.bz2
5.cd php-5.3.1
6. ./configure \
    --with-apxs2=/usr/local/apache2/bin/apxs \
        --with-mysql \
    --prefix=/usr/local/apache2/php 
./configure \
    --with-apxs2=/usr/local/apache2/bin/apxs \
    --prefix=/usr/local/apache2/php

--with-gd[=DIR]
 --with-freetype-dir[=DIR]
--enable-zip
--with-xsl[=DIR]
--enable-ftp
--enable-mbstring
--with-mcrypt[=DIR]


(To know more ./configure --help)



7.make (if u do it again install do a "make clean")
8.make test
9.make install
10.If file /usr/local/apache/modules/libphp5.so does not exist or is an older version, type this (change this to libphp4.so for PHP 4):

    cp -p .libs/libphp5.so /usr/local/apache/modules
11.In httpd.conf
# Use for PHP 5.x:
#Add at the end of the file
#LoadModule php5_module        modules/libphp5.so
AddHandler php5-script php 
AddType application/x-httpd-php-source phps


# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html       php

12.cd /usr/local/apache2/htdocs
13.vim index.php
--------------------
<?php phpinfo(); ?>
--------------------
14./usr/local/apache2/bin/apachectl restart
15.lynx www.vicky12q.com
16.You should see the phpinfo page.`


ioncube :-

http://www.jdam.us/2009/10/09/linux-how-to-install-ioncube-loader/
================================================================================================
================================================================================================
================================================================================================
MYSQL n PHP GALLERY
wget http://nchc.dl.sourceforge.net/project/gallery/gallery2/2.3/gallery-2.3-full.tar.gz

1.yum install mysql*
      or
  yum list |grep mysql*
      here install 3 files i386,server,dlevel
2.service mysqld start
mysql>  create database gallery2;
mysql>  show databases;
mysql> CREATE USER 'vicky'@'localhost' IDENTIFIED BY 'vicky';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'vicky'@'localhost'
    ->     WITH GRANT OPTION;
3.cd /usr/local/apache2/htdocs/
4.wget http://nchc.dl.sourceforge.net/project/gallery/gallery2/2.3/gallery-2.3-full.tar.gz
5.tar -zxvf gallery-2.3-full.tar.gz
6.cd gallery2
7.go to firefox and 192.168.2.245/gallery2 and so the steps 

/usr/bin/mysqladmin -u root password 'new-password'

================================================================================================
================================================================================================
==============================/etc/rc.d/init.d/httpd restart==================================================================
SUB DOMAIN

1.in vim /var/named/vicky12q.com.db
write
subd            IN      A       192.168.2.245

2.in 
vim /usr/local/apache2/conf/httpd.conf
write

NameVirtualHost 192.168.2.245:80

####################################################
<VirtualHost 192.168.2.245:80>
ServerName vicky12q.com
DocumentRoot "/usr/local/apache2/htdocs/"              <--- is alreasy present
</VirtualHost>
###################################################

<VirtualHost 192.168.2.245:80>
ServerName subd.vicky12q.com
DocumentRoot "/usr/local/apache2/htdocs/new/"
</VirtualHost>

3./usr/local/apache2/bin/apachectl restart

4.service named restart

5.lynx www.subd.vicky12q.com

================================================================================================
================================================================================================
================================================================================================
CGI

  1.go to the apache installation directory
  2. ./configure --enable-cgi
  3.make
  4.make install
  5.vim /usr/local/apache2/conf/httpd.conf
    (check scirptalias)   
    find / -name *cgi*
  6.cd /usr/local/apache2/cgi-bin
  7.ls
    chmod 777 printenv
  7./usr/local/apache2/bin/apachectl restart
  8.lynx vicky12qv.com/cgi-bin/test-cgi
  9.goto /usr/local/apache2/conf/httpd.conf
         now add handler
                Addhandler php_script.php
                Action php_script /cgi-bin/php-cgi

  10.Now in Each virtual host add
         options ExecCGI
         scriptAlias /cgi-bin/ "usr/local/apache/htdocs"

   11.now copy -php-CGI in /usr/local/apache to /usr/local/apache/htdocs/bin/CGI



---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
rm -rf ---->to remove a directory.......
du -f  ------->disk quota..

Virtual Host

<VirtualHost 192.168.2.154:80>
 #  ServerAdmin webmaster@dummy-host2.example.com
   DocumentRoot "/usr/local/apache2/htdocs/ram"
   ServerName addon.com
   ServerAlias ram.exam.com
   ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
   DirectoryIndex "index.php"
   Options +ExecCGI
    #Redirect / http://addon.com
#    ErrorLog "logs/dummy-host2.example.com-error_log"
 #   CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
inside ifmodule type the below line
   ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
out side ifmodule type
 AddHandler php5-script .php
       Action php5-script "/cgi-bin/php-cgi"

##############################################################################
type php -i |grep php.ini
this will show where this php.ini files should be available by default
copy php.ini-recommended or php.ini-development as php.ini in those
locations.Or if you want to activat

ssh defined for one user



Configure ssh:
1.goto: vim /etc/ssh/sshd_config
   port 22315
   PermitRootLogin  on

2.goto root: $useradd ragul //username
             $passwd  ragul 
New password:
 re-type password:

3.Type :$vim sudoers
  copy line "root all=(all)"
and paste-edit to "ragul all=(all)".This creats a user "ragul"
with root permission. 

4.Disable ssh login for others,to allow only for our login goto:
$vim /etc/hosts.allow
 EDIT:
 $ssh:192.168.2.158 //type your IP address

5.Restart sshd service :
 $service sshd restart

6.Open another terminal and then type:
 $ ssh -l root 192.168.2.158 -p 22315 //last is port no.
 ->output: Permission denied

7.$ssh -l ragul 192.168.2.158 -p 22315
8.$sudo su

Php forms

phpBB(FORUMS):
configure php with mysql i.e(./configure --with-mysql)
  wget http://www.phpbb.com/files/release/phpBB-3.0.8.tar.bz2
   bunzip2 phpBB-3.0.8.tar.bz2
    tar -xvf phpBB-3.0.8.tar
   cp -R  phpBB3 /usr/local/apache/htdocs/
   change the document root in the virtual hosts where the phpbb3 resides
   restart apache
   http://192.168.2.123/phpBB3 (type it in browser)

post nuke.....

POSTNUKE:
 dont configure and make,make install.(http://www.sfr-fresh.com/unix/www/PostNuke-0.764.tar.gz/)
 yum install mysql*
 download and un-tar postnuke and copy it to /usr/local/apache/htdocs
 output:   
 http://192.168.2.158/PostNuke-0.764



pls follow this along with php with cgi script....

php with cgi

PHP + CGI :
1)yum install perl* (/usr/bin/perl)

2)configuration file:
cd /usr/local/apache/htdocs/
mkdir domain123
vim index.php
<?php
phpinfo();
?>

<VirtualHost 192.168.2.159:80>
#    ServerAdmin webmaster@diummy-host.example.com
AddHandler php5-script php
AddType application/x-httpd-php-source phps
LoadModule php5_module        modules/libphp5.so
    DocumentRoot /usr/local/apache/htdocs/domain123
    DirectoryIndex index.php
    ServerName domain123.com
php_value memory_limit 128M
php_admin_flag safe_mode On
</VirtualHost>


cd /usr/local/apache/htdocs/
vim index.cgi ( download it from net and http://personal.cityu.edu.hk/CGIWrap/cgi_sam.htm)
edit perl location in the first line

<VirtualHost 192.168.2.159:80>
AddHandler php5-script .php
AddHandler cgi-script .cgi
ScriptAlias /cgi-bin /usr/bin/
#AddType application/x-httpd-php-source phps
Action php5-script cgi-bin/perl
Options +ExecCGI
    DocumentRoot /usr/local/apache/htdocs
   DirectoryIndex index.cgi
    ServerName sub.domain123.com
</VirtualHost>






apache commands

  Example 2-3. Example commands for restarting Apache

1. Several Linux and SysV variants:
/etc/rc.d/init.d/httpd restart

2. Using apachectl scripts:
/path/to/apachectl stop
/path/to/apachectl start

3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl:
/path/to/httpsdctl stop
/path/to/httpsdctl start

4. Using mod_ssl, or another SSL server, you may want to manually
stop and start:
/path/to/apachectl stop
/path/to/apachectl startssl

gallery

GALLERY2:
wget http://nchc.dl.sourceforge.net/project/gallery/gallery2/2.3/gallery-2.3-full.tar.gz
 1.yum install mysql*
2.service mysqld start
mysql>  create database gallery2;
mysql>  show databases;
mysql> use databases;
mysql> CREATE USER 'exampleoo'@'localhost' IDENTIFIED BY 'exampleoo';
mysql> GRANT ALL PRIVILEGES ON .* TO 'exampleoo'@'localhost'  WITH GRANT OPTION;
3.cp -R  gallery2 /usr/local/apache2/htdocs/
5.cd gallery2
7.go to firefox and 192.168.2.245/gallery2 and so the steps

yum install gd*
cp -pr php5.* php-gal
cd php-gal
./configure --prefix=/usr/local/php-gal --with-gd --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs               
make
make install

For reference==http://codex.gallery2.org/Gallery2:How_do_I_Install_Gallery2

IN Browser: 192.168.2.158/gallery2

install->2nd step->key generate->copy key->/usr/local/apache2/htdocs/gallery2/login.txt (create this file)
In htdocs
mkdir g2data (edit the username and password)

Wednesday, 16 March 2011

Add on help for linux learner

1.set up a domain addon1.com which should resolve in dns.The mail of
addon1.com should point to gmail mail server.

  $TTL    86400
$ORIGIN sym.com.
@               IN SOA  ns.sym.com.       root.sym.com. (
                                        2011022300              ; serial (d. adams)
                                        900             ; refresh
    

                                  900             ; retry
                                        900             ; expiry
                                        900 )           ; minimum


sym.com.        IN A            192.168.2.158
                       IN NS                ns.sym.com.
                       IN MX   10   gmail.com.
      
ns                   IN A            192.168.2.158

Output:            
[root@158 ~]# host sym.com
sym.com has address 192.168.2.158
sym.com mail is handled by 10 gmail.com.

2)for a sub domain add a entry in your main domain db file

  $TTL    86400
$ORIGIN sym.com.
@               IN SOA  ns.sym.com.       root.sym.com. (
                                        2011022300              ; serial (d. adams)
                                        900             ; refresh
                                        900             ; retry
                                        900             ; expiry
                                        900 )           ; minimum


sym.com.        IN A            192.168.2.158
                 IN NS                ns.sym.com.
ns              IN A            192.168.2.158
sym2             IN A   192.168.2.158 //subdomain entry


goto cd /usr/local/apache2/htdocs/
      mkdir sym2
      vim index.html
goto cd /usr/local/apache2/conf/extra/
     vim httpd-vhosts.conf
Main domain:
    <VirtualHost 192.168.2.158:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/local/apache2/htdocs"
    ServerName sym.com
DirectoryIndex index.html
#Redirect / http://www.gmail.com
#DirectoryIndex index.html index.php
    #ServerAlias www.dummy-host.example.com
    #ErrorLog "logs/dummy-host.example.com-error_log"
    #CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

sub-domain & addon-domain :
<VirtualHost 192.168.2.158:80>
   DocumentRoot "/usr/local/apache2/htdocs/sym2"
    ServerName sym2.com              //addon domain
ServerAlias sym2.sym.com             //subdomain
 </VirtualHost>
restart
lynx sym.com
lynx sym2.com
lynx sym2.sym.com  //addon domain
lynx sym.com/sym2  //sub domain