Wednesday, February 23, 2011

How Install PHPMyAdmin

I want to be clear, all these posts are my way to install these softwares, may be there are other ways better than mine, but as I said it is my way :)
  • Install rpmforge repo
# rpm   -Uvh   epel-release-5-4.noarch.rpm
# rpm   -Uvh   remi-release-5.rpm
  • I will install here some pre requests, may be I installed more than the required softwares. 
# yum --enablerepo=remi install php
# yum --enablerepo=remi install mysql-server
# yum --enablerepo=remi install php-mysql
# yum --enablerepo=remi install php-pear php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml
# yum --enablerepo=remi install phpmyadmin
# vi /etc/httpd/conf.d/phpMyAdmin.conf
allow from all
# service mysqld start
# /usr/bin/mysqladmin -u root password 'mypassword'
# service httpd restart



phpmyadmin URL:
then use a valid mysql user.

Done 
Inas

Tuesday, February 22, 2011

How Install Apache and PHP


This guide shows howto install Apache HTTP Server (httpd) with PHP 5.3.3 and following modules:
·         PEAR
·         PDO
·         MySQL
·         PostgreSQL
·         Memcache
·         GD
·         XML
·         MBString
·         MCrypt
on Fedora 14/13/12/11/10/9/8/7/6, CentOS 5.4/5.5 and Red Hat (RHEL) 5.4/5.5/6systems.

Install Apache HTTP Server (httpd) and PHP 5.3.3

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS and Red Hat (RHEL)
!! Down Load epel-release-5-4.noarch.rpm, remi-release-5.rpm

rpm -Uvh epel-release-5-4.noarch.rpm
 
rpm -Uvh remi-release-5.rpm

3. Install Apache (httpd) Web server and PHP 5.3.3

Fedora 13 (12, 11, 10, 9, 8, 7), CentOS 5.5 and Red Hat (RHEL) 5.5

yum --enablerepo=remi install httpd php php-common

4. Install PHP 5.3.3 modules

Select what you need: PEAR, PDO, MySQL, PostgreSQL, Memcache, GD, MBString, MCrypt, XML

Fedora 13 (12, 11, 10, 9, 8, 7), CentOS 5.5 and Red Hat (RHEL) 5.5

yum --enablerepo=remi install php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml

5. Start Apache HTTP server (httpd) and autostart Apache HTTP server (httpd) on boot

/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update
 
chkconfig --levels 235 httpd on

6. Create test PHP page to check that Apache, PHP and PHP modules are working

Add following content to /var/www/html/test.php file.
<?php
 
    phpinfo();
 
?>

7. Check created page with browser

Access following address, with your browser. http://localhost/test.php

Enable Remote Connection to Apache HTTP Server (httpd) –> Open Web server Port (80) on Iptables Firewall (as root user again)

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following line before COMMIT:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

3. Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

4. Test remote connection

Access following address, with your browser. http://your.domain/test.php


·         To remove a previous PHP version:
# yum  list       php
# yum remove                        php

·         Apache root directory is: /var/www/html

 

Permanently redirect users to access the site WITH or WITHOUT the 'www.' prefix

1.   Create/Open a .htaccess file in the document root folder and add the following text replacing variables with appropriate values where necessary
# mod_rewrite
<IfModule mod_rewrite.c>
  # Enable mod_rewrite engine
  RewriteEngine on

  # WITH 'www.'
  RewriteCond %{HTTP_HOST} ^$uri\.$tld$ [NC]
  RewriteRule ^(.*)$ http://www.$domain$1 [L,R=301]

  # WITOUT 'www.'
  RewriteCond %{HTTP_HOST} ^www\.$uri\.$tld$ [NC]
  RewriteRule ^(.*)$ http://$domain/$1 [L,R=301]
</IfModule>



Done 
Inas

How Install FTP Server on CentOS

  •   To set up ftp server

# yum list vsftpd
# yum install vsftpd

FTP configuration file is:  /etc/vsftp/vstpd.conf

  •   To start FTP server

                   # service vsftpd start


mget  -i *

To change the greeting banner for vsftpd, add the following directive to the /etc/vsftpd/vsftpd.conf file:
         ftpd_banner=<insert_greeting_here>

Replace <insert_greeting_here> in the above directive with the text of the greeting message.
For mutli-line banners, it is best to use a banner file. To simplify management of multiple banners, place all banners in a new directory called /etc/banners/. The banner file for FTP connections in this example is /etc/banners/ftp.msg.
To reference this greeting banner file for vsftpd, add the following directive to the/etc/vsftpd/vsftpd.conf file:
         banner_file=/etc/banners/ftp.msg 

  • As an FTP user if you are not be able to list your home directory, check /etc/sysconfig/iptables-config and add the following:


IPTABLES_MODULES=”  …..  …..  ip_conntrack_ftp”


Done 
Inas

Monday, February 21, 2011

Tips For CentOS.

SΑ,
 I will start with some tips for CentOS, I am using them all the time. So, I thought may be some one else will need and use them.

  •    Use
      # ifconfig  -a             //to see your NIC is up or not (eth0)


  • GUI tool to configure your network.
     # system-config-network &


  •  To check your wireless connection use:
     # iwlist
     # iwlist        wlan0                   scan
  
  • To show the IP routing table:
     # route        -n
 
  •  There is a work around to enable your wireless card
          1.     Install NDIS wrraper
          # rpm          --import      …./RPM-GPG-key-…
         # rpm          -Uvh           …./elrepo…….rpm
        # yum         --enablerepo=elrepo       install                   kmod-ndiswrraper
       #modprobe ndiswrraper
      # ndiswrraper       -i       /..path-to-the-driver/hardware.inf  & .sys file

  • To mount NTFS on Centos:
          1.     Install rpmforge repository, download it for x86-64, check that using:         
          # uname  -i

          Install DAG's GPG key
          # rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

         Verify the package you have downloaded
# rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm
         
          Install the package
# rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
This will add a yum repository config file and import the appropriate GPG keys.
         # yum                   install          fuse   fuse-ntfs-3g
        # yum                   --enablerepo=rpmforge  install                   fuse   fuse-ntfs-3g

       Create a mount point
       # mkdir       /mymount/ /mymount/win/
       # vi    /etc/fstab
       /dev/sda1    /mymount/win      ntfs-3g        rw,umask=0000,defaults           0      0
       # mount /mymount/win
  • To increase the time out before the default OS starting:
       # vi    /boot/grup/menu.lst
       Timeout=30                   (in sec)
 
  • To install a new repository
      Download the repository .rpm
      Verify the package you have downloaded
     # rpm –K    ……rpm
     # rpm          -Uvh  ……rpm
     # yum          --enable-repo=”Repo-name”    install   “Required package”
 
  • If you face any problem with enabling the network
         1.     Check         /etc/sysconfig/network
               Gateway=”Gateway IP”
         2.     Check         /etc/resolv.conf
                 nameserver “DNS IP”
         3.     Check the default gateway using:      # route
                 If it is not correct delete it using:
           # /sbin/route                   del     default        gw     GW-IP
           Add the correct one:
           # /sbin/route                   add    default        gw     GW-IP
  
 
  •  Wget is a very cool command-line down loader for Linux and UNIX environments. 
 It is very powerful and versatile and can match some of the best graphical downloaders around today. It has features such as resuming of downloads, bandwidth control, it can handle authentication, and much more.
Most Linux distributions come with wget pre-installed. 
The most basic operation a download manager needs to perform is to download a file from a URL. Here’s how you would use wget to download a file:
# wget http://www.sevenacross.com/photos.zip
 
  • Display TOTAL hard disk size
      # fdisk -l | grep Disk

  • To disable SELinux:
      # vi   /etc/selinux/config
          Selinux=disable
 
          Or : #  setenforce  0
          Or : #  lokkit     //Firewall and SELinux configuration tool.
 
  •  To check md5
         # md5sum   file-name

  • To list CPU info
     # more /proc/cpuinfo
 
  • To check the RAM Size in Linux Machine
      # free -m
 
  • To disable ping responses
      #  echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
OR
      #sysctl   -w   net.ipv4.icmp_echo_ignore_all=1
 
  • To enable ping responses
     #  echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
OR
     #sysctl   -w   net.ipv4.icmp_echo_ignore_all=0
 
  •  To make this permanent set the following into /etc/sysctl.conf
             net.ipv4.icmp_echo_ignore_all=1
 
How to Assign an IP Address Using ifconfig Command Line Tool?
 
# cp /etc/sysconfig/network-scripts/ifcfg-eth1      /etc/sysconfig/network-scripts/ifcfg-eth1.bak
ifconfig eth1 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255
The ifconfig command does not store these changes permanently. Upon reboot this information is lost. To make your changes permanent, open the file /etc/sysconfig/network-scripts/ifcfg-eth1 and enter the following information.

Static IP configuration


 
DEVICE=eth1

BOOTPROTO=static

BROADCAST=XXX.XXX.XXX.255

IPADDR=XXX.XXX.XXX.XXX

NETMASK=255.255.255.0

NETWORK=XXX.XXX.XXX.0

ONBOOT=yes

DHCP configuration


DEVICE=eth1

ONBOOT=yes

BOOTPROTO=dhcp


Once you have made changes to the files above, you can make the network card use the new values without any reboot by running the following command.

# ifup eth1

ifup is a script residing in /etc/sysconfig/network-scripts/ifup, which is used to bring network interfaces on-line.

Note: To disable DHCP change BOOTPROTO=dhcp to BOOTPROTO=none in the ifcfg-eth1 file above.

In order for updated information in any of these files to take effect, one must issue the command:

# service network restart
  
  • Setting a Default Gateway for Redhat / CentOS systems?
There are two possible ways for adding a default gateway.
Option 1: You can add a gateway definition to  the /etc/sysconfig/network file. This definition will apply to all network interfaces.
/etc/sysconfig/network file.

GATEWAY=192.168.4.1
 
Option 2: You can define a default gateway for a specific interface. For this approach you need to modify your interface definition. Let’s say we want to modify eth0 then you need to add the same definition to the  /etc/sysconfig/network-scripts/ifcfg-eth0 file.
For both options, your modifications will be activated after you restart your networking service.
root@centos ~]# /etc/init.d/networking restart

I hope if any one have any question or any comment will not hesitate to tell me.

Done.
Inas