วันศุกร์ที่ 3 สิงหาคม พ.ศ. 2555

How to Set JAVA_HOME / PATH variables Under Linux Bash Profile


~/.bash_profile is a startup script which generally runs once. This particular file is used for commands which run when the normal user logs in. Common uses for .bash_profile are to set environment variables such as PATH, JAVA_HOME, to create aliases for shell commands, and to set the default permissions for newly created files.

Set JAVA_HOME / PATH for a single user

Login to your account and open .bash_profile file
$ vi ~/.bash_profile
Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:
export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
Set PATH as follows:
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Feel free to replace /usr/java/jdk1.5.0_07 as per your setup. Save and close the file. Just logout and login back to see new changes. Alternatively, type the following command to activate the new path settings immediately:
$ source ~/.bash_profile
OR
$ . ~/.bash_profile
Verify new settings:
$ echo $JAVA_HOME
$ echo $PATH

Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java
Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.

Set JAVA_HOME / PATH for all user

You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

Save and close the file. Once again you need to type the following command to activate the path settings immediately:
# source /etc/profile
OR
# . /etc/profile
Tag: set java home linux, linux java home, java home linux, java home in linux, find java home linux

CentOS Web server with Latest Apache, PHP and MySQL


Make sure you have installed CentOS with minimal system tools.
I am going to use my home directory as root folder.
cd ~
import RPM-GPG-KEY
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
Update Everything using YUM
yum -y update
Reboot your Server.
reboot
Install Some Required Packages
yum install fetchmail wget bzip2 unzip zip nmap openssl lynx fileutils
Setup System Time
yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
/etc/init.d/ntpd start
Install RPMForge Repo
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm
 
yum clean all
yum update
Use Remi’s Repo for Latest PHP and MySQL
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
Enable Remi’s Repo
nano /etc/yum.repos.d/remi.repo
 
[remi]
enabled=1
Install Apache and PHP Server
yum install httpd
chkconfig --levels 235 httpd on
yum install php php-mysql php-gd php-odbc php-pear php-xml php-xmlrpc curl perl-libwww-perl ImageMagick libxml2
 
## Edit Apache Configuration, if you need.
nano /etc/httpd/conf/httpd.conf
Install MySQL Server
yum install mysql mysql-server
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
 
## Change your MySQL Password
mysql_secure_installation
 
## Check if MySQL is running
netstat -tap | grep mysql
 
## Edit MySQL Configuration, if you need.
nano /etc/my.cnf
Install eAccelerator – PHP Caching, Makes your php load faster
yum install php-eaccelerator
Install PhpMyAdmin
yum install phpmyadmin
Start Apache Server
service httpd restart
Check Apache
apachectl -M
Output
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 ...
Syntax OK
Check PHP
php -v
Output
PHP 5.3.6 (cli) (built: May 16 2011 19:18:00)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
Web server with Latest PHP and MySQL is done!
Install Webmin if you want
yum install openssl perl-Net-SSLeay
rpm --import http://www.webmin.com/jcameron-key.asc
Add Webmin Repo
nano /etc/yum.repos.d/webmin.repo
Add This
[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
Install Webmin
yum install webmin
TAG: linux server hosting, hosted linux server, linux server host, dedicated linux server hosting, linux dedicated server hosting, linux home server, home linux server, linux home server software, linux server home, linux home servers

วันเสาร์ที่ 28 กรกฎาคม พ.ศ. 2555

How To Enable or Disable SELinux


From the command line, you can edit the /etc/sysconfig/selinux file. This file is a symlink to/etc/selinux/config. The configuration file is self-explanatory. Changing the value of SELINUX orSELINUXTYPE changes the state of SELinux and the name of the policy to be used the next time the system boots.
[root@host2a ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
Changing the Mode of SELinux Using the GUI
Use the following procedure to change the mode of SELinux using the GUI.
  1. On the System menu, point to Administration and then click Security Level and Firewall to display the Security Level Configuration dialog box.
  2. Click the SELinux tab.
  3. In the SELinux Setting select either DisabledEnforcing or Permissive, and then click OK.
  4. If you changed from Enabled to Disabled or vice versa, you need to restart the machine for the change to take effect.
Changes made using this dialog box are immediately reflected in /etc/sysconfig/selinux.


วันพฤหัสบดีที่ 26 กรกฎาคม พ.ศ. 2555

[E-mail] Can not mount NFS in Ubuntu with CentOS 6.3

Hi everybody

I'm using ubuntu 12.04.LAN IP is 192.168.1.36

I install Virtual Box. In virtual box I install CentOS 6.3. LAN IP is 192.168.56.102

2 computers can ping success

I want to mount folder in CentOS /home/www/web/uploads to /home/nfs (in Ubuntu)

Ubuntu: rootmkdir /home/nfs
/etc/init.d/nfs-kernel-server start
service portmap start
in /etc/exports I add /home/nfs 192.168.56.102(rw,insecure,no_root_squash)

In CentOS:mount -t nfs 192.168.1.36:/home/nfs /home/www/web/uploads

Error: mount.nfs: access denied by server while mounting 192.168.1.36:/home/nfs

Please help me solve this problem

Thank you very much
-------------------


Hi,
Once run "exportfs -av", and once restart portmap and nfs-kernel-server services,
after that try to mount again , in case if you face any issue , please check "tail -f /var/log/syslog"
you can also check following things from client machine
showmount -e <NFS_SERVER_IP> # it will show you nfs settings
also check following command from client side
rpcinfo -p <NFS_SERVER_IP>



Display number of processors on CentOS


Quick question - How do I display number of processors on linux?


Simply use top command:

top

Get info from /proc/cpuinfo with the help of grep command

grep -c processor /proc/cpuinfo

Mounting cd drive in CentOS

Follow  the command to mount a cdrom in CentOS


CD Rom
mount /dev/cdrom /mnt



DVD Rom
mount /dev/dvd /mnt

วันพุธที่ 25 กรกฎาคม พ.ศ. 2555

Remove all i386 packages from CentOS 5 x86_64


A quick solution to duplicate packet installation. This tutorial will show you how to remove all i386 packages from CentOS 5 x86_64 server
yum remove \*.i\?86

How To Adding Swap Space On CentOS

Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system from 128 MB to 256 MB, but there is only 256 MB of swap space. It might be advantageous to increase the amount of swap space to 512 MB if you perform memory-intense operations or run applications that require a large amount of memory.


To add a swap file:
  1. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
  2. At a shell prompt as root, type the following command with count being equal to the desired block size:
    dd if=/dev/zero of=/swapfile bs=1024 count=65536
    
  3. Setup the swap file with the command:
    mkswap /swapfile
    
  4. To enable the swap file immediately but not automatically at boot time:
    swapon /swapfile
    
  5. To enable it at boot time, edit /etc/fstab to include the following entry:
    /swapfile          swap            swap    defaults        0 0
    
    The next time the system boots, it enables the new swap file.
  6. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.