Monday, November 24, 2014

CentOS 7 tips

Stop useing root ssh login

#/etc/ssh/sshd_config
PermitRootLogin no




VirtualBox guest addition


after install centos , update it first

yum update

reboot

then update kernel*

yum update kernel*

reboot

then install devel tool and kernel

yum install gcc kernel-devel kernel-headers dkms make bzip2 perl

then mount guestaddtions iso and install it

mkdir /media/cdrom
mount -r /dev/cdrom /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run

done


//manual mount share folder

mount -t vboxsf share_name vm_folder

// mount on boot (remember do not checked auto mount on Virtual Box)
touch /etc/modules-load.d/vboxsf.conf

// append line "vboxsf" to vboxsf.conf
echo "vboxsf" >> /etc/modules-load.d/vboxsf.conf

vi /etc/fstab
share_name /path/to/vm defaults 0 0

Symlinks in VirtualBox

//after setting , restart Virtual machine and virtualbox

VBoxManage.exe setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1


ifconfig


Centos default didn't have ifconfig command

we can use "ip addr" instend

or 

yum install net-tools

for install ifconfig


service

sudo systemctl start httpd.service
sudo systemctl status httpd.service
sudo systemctl enable httpd.service //on boot
systemctl list-unit-files --type=service


firewall

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --add-source=192.168.1.0/24 --permanent
firewall-cmd --reload

network static

#vi /etc/sysconfig/network-scripts/ifcfg-name

BOOTPROTO=static
IPADDR=192.168.x.x
NETMAST=255.255.255.0
GATEWAY=192.168.x.1

network dns

$ sudo vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

or

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-name

DNS1=8.8.8.8

php-mcrypt


cd /tmp
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm
yum install php-mcrypt*



alias su command

create a custom.sh shell script in  (rember file name have execute order problem)
# /etc/profile.d/custom.sh

alias ll='ls -al'



apache 2.4 Directory new option required

Require all granted