Tuesday 7 July 2015

How to Set SSH Login Email Alerts in CentOS/Redhat Enterprise Linux/Ubuntu/ Debian/Linux Mint /Fedora

On Debian/Ubuntu/Linux Mint
# apt-get install mailx

On RHEL/CentOS/Fedora
# yum install mailx

Set SSH Root Login Email Alerts
# cd /root
# vi .bashrc

Add the following whole line at the bottom of the file. Make sure to replace “ServerName” with a hostname of your Server and change “your@yourdomain.com” with a your email address.

echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" your@yourdomain.com

Save and close the file and logout and log back in. Once you login via SSH, a .bashrc file by default executed and sends you an email address of the root login alert.

Set SSH Normal User Login Email Alerts
Login as normal user (amir) and go to user’s home directory by typing cd /home/amir/ command.

# cd /home/amir

Next, open .bashrc file and add the following line at end of the file. Make sure to replace values as shown above.

#vim .bashrc

echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" your@yourdomain.com

Save and close the file and logout and login again. Once you login back again, a .bashrc file executed and sends you an email address of the user login alert.



Monday 6 July 2015

How to configure vncserver CentOs 6/RHEL 6


Install Desktop Environment

For GNOME:
# yum groupinstall  "General Purpose Desktop" "Desktop Platform"

For KDE:
# yum groupinstall  "KDE Desktop"

Install VNC server
# yum -y install vnc-server

Install   Tigervnc-Server
# yum install tigervnc-server

Make vnc password for user (Ex. amir). Login to the user and run the following command:
#vncpasswd amir
Password:
Verify:
Configure VNC configuration for new user

Edit /etc/sysconfig/vncservers file and add the user name:

#vim /etc/sysconfig/vncservers
VNCSERVERS="2:amir"
VNCSERVERARGS[2]="-geometry 1280x1024"
Save and exit

#service vncserver restart
#chkconfig vncserver on

Done…

Thursday 2 July 2015

How to use .htaccess file on Apache server



You need to have AllowOverride AuthConfig directive in httpd.conf file in order for these directives to have any effect. Look for DocumentRoot Directory entry. In this example, our DocumentRoot directory is set to /var/www. Therefore, my entry in httpd.conf looks like as follows:

<Directory /var/www/html>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Save the file and restart Apache
 
If you are using Red Hat /Fedora Linux:
# service httpd restart


If you are using Debian Linux:
# /etc/init.d/apache-perl restart


Wednesday 1 July 2015

How To Install LAMP Stack On Ubuntu 15.04

How To Install LAMP Stack On Ubuntu 15.04

1. Install Apache
To install Apache…
#apt-get install apache2

Test Apache:
Open your web browser and navigate to http://localhost/ or http://server-ip-address/.

2. Install MySQL
#apt-get install mysql-server mysql-client
During installation, you’ll be asked to setup the MySQL “root” user password. Enter the password and click Ok.
MySQL is installed now.

You can verify the MySQL server status using command:

On Ubuntu 15.04:
#ssystemctl status mysql

On Ubuntu 14.10 and previous versions:
#service mysql status

Mysql initial setting…
#mysql_secure_installation
#service mysql status
3. Install PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:
#apt-get install php5 php5-mysql libapache2-mod-php5

To test PHP, create a sample “test.php” file in Apache document root folder.

#vim /var/www/html/testphp.php
Add the following lines.
<?php
phpinfo();
?>

Restart apache2 service.

On Ubuntu 15.04:
#systemctl restart apache2

On Ubuntu 14.10 and lower versions:
#service apache2 restart

Navigate to http://server-ip-address/test.php. It will display all the details about php such as version, build date and commands etc.

4. Install phpMyAdmin
phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases. It is available in the Official Debian repositories. So install it with command:

#apt-get install phpmyadmin
Select the Web server that should be automatically configured to run phpMyAdmin. In my case, it is apache2.

Enter password of the database’s administrative user.
Enter MySQL application password phpmyadmin.
Re-enter the password.
Success! phpMyAdmin installation is installed.

Additional Note: if you followed all steps carefully, phpMyAdmin should work just fine. In case phpMyAdmin is not working, please do the following steps.
Open terminal, and type:
#vim /etc/apache2/apache2.conf
Add the following line at the end.

Include /etc/phpmyadmin/apache.conf
Save and Exit.

Restart apache service:

On Ubuntu 15.04:
#systemctl restart apache2

On Ubuntu 14.10 and lower versions:
#/etc/init.d/apache2 restart


Done… 

How to enable root login ubuntu-15.04-server

                
The root user in Ubuntu is disabled by default because his password is not set. But if you'd like to use root user by some reason, enable it like follows.

Set root password.

root@amir:~$ sudo passwd root
Enter new UNIX password:                    # set root password
Retype new UNIX password:                # confirm
passwd: password updated successfully

root@amir:~$ su -
Password:                           # root password
root@amir:~                       ## just switched             

If you enable root, limit users to switch to root.

root@amir:~# vi /etc/pam.d/su
# line 15: uncomment and add a group that can switch to root
auth   required   pam_wheel.so   group=adm

root@amir:~# usermod -G adm root

End...

How to install clamAV on Centos 6

  Install EPEL repo: Before we can do proceed, you must ensure that you have the EPEL yum repository enabled. To do this, CentO...