Google+ Badge

Sunday, July 5, 2015

How to Install and Configure Samba Server on RHEL/CentOS

Samba is free software mainly used for file sharing between other platforms (Windows) using  SMB/CIFS protocol. Samba uses TCP/IP protocol. Samba provide file and print sharing service between Linux and Window system. Samba allows Linux to interact with Window client, Server, member of Active Directory, Primary domain controller, or member server. Samba Web Administration tool (SWAT) is a GUI base configuration tool for Samba Serveravailable from RHEL 6.

* Microsoft window use Common Internet File System (CIFS) protocol for networking.
* CIFS was developed from Server Message Block (SMB) protocol.

Linux SAMBA provides the following services => User Authentication and authorization, File and printer sharing, Name resolution, Browsing.

smb => (SMB/CIFS Server) Main samba service which provides user authentication and authorization & file and printer sharing.
nmb => (NetBIOS name server) Resource browsing.

Step 1 - Check the Server IP-Address and OS Details.

Step 2 - Update yum repositories and packages.

Step 3 - Install samba packages along with dependencies using yum.

Step 4 - Create a user and set the samba password for accessing the share folder.

Step 5 - Create a new folder for using the share access and change the ownership for the share folder.

Step 6 - Before changing the configuration file, backup the smb.conf.

Step 7 - Now we want to edit the configuration file and our share folder structure in smb.conf.
     [root@proxy ~]# vim /etc/samba/smb.conf

Note : You can see the share sections. Here by default home folders of the user will be displayed . You can comment the unwanted section using “;” symbol .

Step 8 - After changing the settings, restart the samba service and also enable start samba service automatically while booting.

Step 9 - You can check  your configuration by using testparm command

Step 10 - Now you can access the share folder on windows machine by typing \\samba-server-ip\ on run prompt . You can see the share folder after entering the username and password.

Here, I have created a file and folder for testing the permission.

Step 11 - Here I need to share my Apache document root " /var/www/html/", I have to do these steps.

Set the samba user permission on document root and restart the samba service.

Check the share folder and create test file for checking permissions.

Step 12 -  Try to list share from Samba server with the user.

Step 13 - How to allow Samba in iptables and disable selinux.

SAMBA uses ports 137,138,139 and 445
   Port 137 UDP NetBIOS name service (WINS)
   Port 138 UDP NetBIOS datagram
   Port 139 TCP NetBIOS Session (TCP), Windows File and Printer Sharing
   Port 445 Microsoft-DS Active Directory, Windows shares (TCP)
   Port 445 Microsoft-DS SMB file sharing (UDP)

To open firewall for Samba adds the following rules and restart the iptables.

#iptables -A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT 
#iptables -A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT 
#iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT 
#iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

That's it....

Sunday, June 21, 2015

How to enable mod_rewrite in Ubuntu 14.04

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

Step 1 - Activate the mod_rewrite module using this command.

Step 2 - Now Restart the Apache service.

Step 3 - Now we need to make some changes on Apache configuration file. Here I use "000-default.conf" configuration file and search for “DocumentRoot /var/www/html” and add the following lines.

    vi /etc/apache2/sites-available/000-default.conf
    <Directory "/var/www/html">
          AllowOverride All

Step 4 - Now again restart the Apache service and check the status on "phpinfo.php".

Step 5 - Here I have created a small example of mod-rewrite, put ".htaccess" file in webserver document root for testing.

That's it...

How to Install phpMyAdmin on CentOS/RHEL 7/6/5

PhpMyAdmin is web-based client written in php for managing MySQL and MariaDB databases. It provides a user friendly web interface to access and manage your databases. 

Before installing and configuring phpmyadmin, we need to installing and configuring apache, mysql/mariadb and php.

Step 1 - Before Installing phpMyAdmin, we need to Install/Enable "EPEL or REMI" repository.

EPEL => rpm -ivh
REMI => rpm -Uvh

Step 2 - Update repository and install the package using the below command.

[root@proxy ~]# yum check-update
[root@proxy ~]# yum --enablerepo=remi install phpMyAdmin

Step 3 - Now restart httpd service

Step 4 - Now, we can access phpMyAdmin in browser using the following url. 

Step 5 - phpMyAdmin by default allowed to access from localhost only. If you want to make it accessible from remote computers edit "/etc/httpd/conf.d/phpMyAdmin.conf" and update all with your network OR find the lines “Deny from All ” and comment those lines.

Step 6 -After changing configuration, restart httpd service

Now we can check that it is working fine.

Troubleshooting :

# 2002 – Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)  => The server is not responding (or the local server’s socket is not correctly configured).

( This means your mysql server service is stopped , you must start the service  “service mysql start”).

That's it...

How to Install and configure OpenSSH with basic configuration

OpenSSH is a free open source set of computer tools used to provide secure and encrypted communication over a computer network by using the ssh protocol. Accessing a shell account via SSH may be one of the most secure and easiest ways to access files, run programs, or change system settings. With secure shell it is only possible to run commands in a command line environment, not graphically. 

Step 1 - First change to root user.

Step 2 - To install OpenSSH, open a terminal and run the below command. 
   apt-get install openssh-server openssh-client

Also we can use graphically, go to "Ubuntu Software Center" use below example.

Step 3 - After installing we can see the ssh configuration directory.

Step 4 - Before editing configuration file, backup the sshd_config file.

Step 5 - Now, we can configure ssh configuration file according to our requirement by using "gedit" or "vim".
Note : Here I am using default ssh settings.

Step 6 - After configuration, restart the sshd service.

Step 7 - After configuration go to client / remote PC and connect to server using "putty" or "terminal".
Here I successfully  connected, now I can use my server using ssh.

This method is by using terminal.

That's it....

Friday, June 19, 2015

How to Upgrade PHP 5.4.X TO 5.5.X OR 5.6.X on CentOS 6.X

Step 1 - Check the system OS and Hardware information.

Step 2 - Check the current version of Apache, PHP and MySql.
   And also check PHP dependency versions.

Step 3 - Add EPEL and Remi repositories into your server :

On CentOS 6.x 32-bit :
     rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

On CentOS 6.x x86_64 (64-bit) :
     rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Step 4 - After installing, check the repository is added or not.

Step 5 -  Now enable your newly added Remi repository. Open the /etc/yum.repos.d/remi.repo file using a text editor.

Edit enabled=0 line to enabled=1    => Select the version which you want to enable, go to that PHP version and enable 1. Here I am upgrade version php56.

Step 6 -After enabling "php56", we can upgrade php version by using below command.
   yum --enablerepo=remi,remi-php56 update php\*

Step 7 - After all we can check the PHP and PHP dependency version.

Step 8 - Now restart the Apache server.

Step 9 - We can also check the version in phpinfo.php file.

That's it...