Sunday, January 11, 2015

How to Setup Vsftpd server and Point the Home Directory manually



FTP is used to transfer files from one host to another over TCP network. There are 3 popular FTP server packages available PureFTPD, VsFTPD and ProFTPD. 

If you are login as a normal user, you have to use "sudo" before the command, only for the first time. If your in root login, you can simply use the command, without "sudo".

Step 1 » Update your repositories.
     root@digidom:~# apt-get update

Step 2 » Install VsFTPD package using the below command.
     root@digidom:~# apt-get install vsftpd

Step 3 » Check the vsftpd directories and file paths.
     root@digidom:~# whereis vsftpd


     vsftpd: /usr/sbin/vsftpd /etc/vsftpd.conf /usr/share/man/man8/vsftpd.8.gz


Step 4 » Backup the /etc/vsftpd.con file


     root@digidom:~# cp /etc/vsftpd.conf /etc/vsftpd.conf.back


Step 5 » After installation open /etc/vsftpd.conf file and make changes as follows.

     root@digidom:~# vi /etc/vsftpd.conf

     root@digidom:~# egrep -v '^#|^$' /etc/vsftpd.conf
     listen=YES
     anonymous_enable=NO
     local_enable=YES
     write_enable=YES
     dirmessage_enable=YES
     use_localtime=YES
     xferlog_enable=YES
     chroot_local_user=YES
     allow_writeable_chroot=YES
     connect_from_port_20=YES
     secure_chroot_dir=/var/run/vsftpd/empty
     pam_service_name=vsftpd
     rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
     rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

Step 6 » Restart vsftpd service using the below command.
     root@digidom:~# service vsftpd restart


Step 7 » Create a User account with nologin shell and specify Home Directory location, I point to "/var/www/html/" and set the password. You can specify your own path.

Note : Do not delete this account using "userdel -rf mailftp". It will remove html directory, because this user (mailftp) home directory is /var/www/html/. 


  root@digidom:~# useradd -m -d /var/www/html/ -s /usr/sbin/nologin mailftp

  root@digidom:~# passwd mailftp

Options 1 » If you have any doubt in nologin shell, check the login shell.
     root@digidom:~# cat /etc/shells
          # /etc/shells: valid login shells
          /bin/sh
          /bin/dash
          /bin/bash
          /bin/rbash
          /usr/bin/tmux
          /usr/bin/screen
          /usr/sbin/nologin

If not there /usr/sbin/nologin just add for using this command.

     root@digidom:~# echo "/usr/sbin/nologin" >> /etc/shells

Step 8 » Check the user accounts details
     root@digidom:~# tail /etc/passwd | grep mailftp
          mailftp:x:1001:1001::/var/www/html/:/usr/sbin/nologin

Step 9 » Set the permission.


     root@digidom:~# chown mailftp:root /var/www/html/
     root@digidom:~# ll -d /var/www/html/
          drwxr-xr-x  5 mailftp root 4096 Dec 16 22:55 html/

                                  OR


     root@digidom:~# chown root:mailftp /var/www/html/
     root@digidom:~# chmod -R 775 /var/www/html/
     root@digidom:~# ll -d /var/www/html/
          drwxrwxr-x  5 root mailftp 4096 Dec 16 22:55 html/
     
     root@digidom:~# service vsftpd restart

Step 10 » If another option is create a directory inside of html user home directory point this.


    root@digidom:~# useradd -m -d /var/www/html/ftp -s /usr/sbin/nologin mailftp

    root@digidom:~# passwd mailftp

    root@digidom:~# chown mailftp:mailftp /var/www/html/ftp
    root@digidom:~# ll -d /var/www/html/ftp
          drwxr-xr-x  5 mailftp mailftp 4096 Dec 16 22:55 ftp/

    root@digidom:~# service vsftpd restart

That's it............

How to install XAMPP on windows 7


XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P) and Perl (P). It is a simple, lightweight Apache distribution that makes it extremely easy for developers to create a local web server for testing purposes. Everything you need to set up a web server – server application (Apache), database (MySQL), and scripting language (PHP) – is included in a simple extractable file. XAMPP is also cross-platform, which means it works equally well on Linux, Mac and Windows. 


Step 1 - Download XAMPP setup from website:


Step 2 - Disable your anti-virus as it can cause some XAMPP components to behave erratically.

Step 3 - Start the installation process by double-clicking on the XAMPP installer.


Step 4 - For Windows 7 users, you will see a window pop up, warning you about User Account Control (UAC) being active on your system. Click OK to continue the installation.


Step 5 - Next you will see the Welcome to the XAMPP setup wizard screen. Click Next to continue the installation.


Step 6 - Choose the folder you want to install XAMPP. This folder will hold all your web application files, so make sure to select a drive that has plenty of space.


Step 7 - The next screen is a promo for BitNami, an app store for server software. Deselect the ‘Learn more about BitNami for XAMPP’ checkbox, unless you actually enjoy receiving promo mails.


Step 8 - Setup is now ready to install XAMPP. Click Next and wait for the installer to unpack and install selected components. This may take a few minutes.



Step 9 - Installation is now complete! Select the ‘Do you want to start the Control Panel now?’ checkbox to open the XAMPP control panel.


Step 10 - The XAMPP control panel gives you complete control over all installed XAMPP components and tart the apache and mysql.


Step 11 - Test the XAMPP, open your web browser and type in: http://localhost or 127.0.0.1. Select your language from the splash screen.


You should see the following screen. This means you’ve successfully installed XAMPP on your computer.

Step 12 - We will now test whether XAMPP has installed PHP successfully. Open Notepad and type the following into a new document:

     <?php
       phpinfo();
     ?>

Save this file as ‘test.php’ in c:\xampp\htdocs\ (or whichever directory you installed XAMPP in).
Navigate to http://localhost/phpinfo.php. You should see the “Hello World” message


Step 13 - You can access phpMyAdmin by entering http://localhost/phpmyadmin in your web browser.


That's it.....

Wednesday, December 24, 2014

How to Install Phpmyadmin in Ubuntu 14.04

How to Install Phpmyadmin in ubuntu 14.04

Phpmyadmin is a free tool used to administrative MySQL database in a GUI mode (Using web browser). You can perform almost all the major tasks like creating , deleting  and modifying databases, tables, rows etc. you can also optimize and repair tables just with a single click .

Note : Before you get started with this, you need to install LAMP or MySql-Server on this server.

Step 1 - Update Ubuntu repositories and install phpmyadmin
     root@digidom:~# apt-get update
     root@digidom:~# apt-get install phpmyadmin

Step 2 - During installation you will be asked to select a Web server to run the phpmyadmin interface. Hit "SPACE", "TAB", and then "ENTER" to select Apache.

Step 3 - You will be asked to configure a database for phpMyAdmin.  Select Yes and press Enter.


Note : If you already configured mysql-server manually, just choose “No” and hit enter to complete the installation.


Step 4 - Provide a password for the Database Administrative user.


Step 5 - Provide a MySQL application password for phpmyadmin.


Success, phpMyAdmin installation has been completed now.

Step 6 - The installation process actually adds the phpMyAdmin Apache configuration file into the "/etc/apache2/conf-enabled/ "Directory, where it is automatically read.

Step 7 - Restart apache service.
     root@digidom:~# service apache2 restart

Step 8 - Launch a Web browser and login to phpMyAdmin with the username and password created during installation "http://Your-Server-IP-Address/phpmyadmin/".
You will be redirected to PhpMyAdmin main web interface.

Now, you can manage your MySQL databases from phpMyAdmin web interface.

Additional Note : phpMyAdmin should work well. In case phpMyAdmin is not working "page not found", please do the following steps and add to end of line.

     root@digidom:~# vi /etc/apache2/apache2.conf
     Include /etc/phpmyadmin/apache.conf
     root@digidom:~# service apache2 restart

That’s it......

Tuesday, December 23, 2014

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04


About LAMP
LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. The user to have root privileges on your VPS.

Step 1 - Install Apache :
Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and Virtual domains.

     root@digidom:~# sudo apt-get update
     root@digidom:~# sudo apt-get install apache2

How to Find your Server’s IP address :

     root@digidom:~# ifconfig eth0 | grep inet | awk '{ print $2 }'

That’s it. To check if Apache is installed, go to your browser and enter your server’s IP address (Eg. http://Your-Server-IP Address).



Step 2 - Install MySQL :

MySQL is a powerful database management system used for organizing and retrieving data. MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases, though SQLite probably has more total embedded deployments.

    root@digidom:~# sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss this step while the program is installing, it is very easy to set the password later from within the MySQL shell.

Re-enter the password.


To check the mysql  Directory locations :

     root@digidom:~# whereis mysql 
          mysql:/usr/bin/mysql  /etc/mysql  /usr/lib/mysql  /usr/share/mysql     /usr/share/man/man1/mysql.1.gz


To create Database directory structure :

Once you have installed MySQL, we should activate it with this command "mysql_install_db"




To run security script that will remove default setting :

Afterwards, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Start the interactive script by running  "mysql_secure_installation".

 


Restart mysql service and Check the mysql status :
      



Step 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.

     root@digidom:~# apt-get install php5 libapache2-mod-php5 php5-mcrypt

     root@digidom:~# php -v
     PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
     Copyright (c) 1997-2014 The PHP Group
     Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend      OPcache v7.0.3,       Copyright (c) 1999-2014, by Zend Technologies


Modify apache server file and Add index.php to begin :

If a user requests a directory from the server, Apache will first look for a file called index.html. We want to tell our web server to prefer PHP files, so we'll make Apache look for an index.php file first.

     root@digidom:~# vi /etc/apache2/mods-enabled/dir.conf
          <IfModule mod_dir.c>
                 DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
          </IfModule>

Check the PHP Modules :

PHP also has a variety of useful libraries and modules that you can add onto your virtual server. You can see the libraries that are available.

root@digidom:~# apt-cache search php5-
php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-json - JSON module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-readline - Readline module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-tidy - tidy module for php5
php5-xmlrpc - XML-RPC module for php5
php5-xsl - XSL module for php5
ibphp5-embed - HTML-embedded scripting language (Embedded SAPI library)
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-apcu - APC User Cache for PHP 5
php5-enchant - Enchant module for php5
php5-exactimage - fast image manipulation library (PHP bindings)
php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php5-gdcm - Grassroots DICOM PHP5 bindings
php5-gearman - PHP wrapper to libgearman
php5-geoip - GeoIP module for php5
php5-gnupg - wrapper around the gpgme library
php5-imagick - ImageMagick module for php5
php5-imap - IMAP module for php5
php5-interbase - interbase/firebird module for php5
php5-intl - internationalisation module for php5
php5-lasso - Library for Liberty Alliance and SAML protocols - PHP 5 bindings
php5-librdf - PHP5 language bindings for the Redland RDF library
php5-mapscript - php5-cgi module for MapServer
php5-mcrypt - MCrypt module for php5
php5-memcache - memcache extension module for PHP5
php5-memcached - memcached extension module for PHP5, uses libmemcached
php5-midgard2 - midgard2 Content Repository - PHP5 language bindings and module
php5-ming - Ming module for php5
php5-mongo - MongoDB database driver
php5-msgpack - PHP extension for interfacing with MessagePack
php5-mysqlnd - MySQL module for php5 (Native Driver)
php5-mysqlnd-ms - MySQL replication and load balancing module for PHP
php5-oauth - OAuth 1.0 consumer and provider extension
php5-pinba - Pinba module for PHP 5
php5-ps - ps module for PHP 5
php5-radius - PECL radius module for PHP 5
php5-redis - PHP extension for interfacing with Redis
php5-remctl - PECL module for Kerberos-authenticated command execution
php5-rrd - PHP bindings to rrd tool system
php5-sasl - Cyrus SASL Extension
php5-stomp - Streaming Text Oriented Messaging Protocol (STOMP)client module for PHP 
php5-svn - PHP Bindings for the Subversion Revision control system
php5-sybase - Sybase / MS SQL Server module for php5
php5-tokyo-tyrant - PHP interface to Tokyo Cabinet's network interface, Tokyo Tyrant
php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
php5-xcache - Fast, stable PHP opcode cacher
php5-xdebug - Xdebug Module for PHP 5
php5-xhprof - Hierarchical Profiler for PHP5


Once you decide to install the module, type :

     root@digidom:~#  sudo apt-get install "name of the module"



Step 4 - Check LAMP Server :

Although LAMP is installed, we can still take a look and see the components online by creating a quick php info page.

To test PHP, create a sample “phpinfo.php” file in Apache Document Root folder.


Then Save and Exit. 

Restart apache and mysql :

      root@digidom:/var/www/html# /etc/init.d/apache2 restart
      * Restarting web server apache2                         [ OK ]

      root@digidom:/var/lib/mysql# /etc/init.d/mysql  restart
      * Stopping MySQL database server mysqld           [ OK ]
      * Starting MySQL database server mysqld            [ OK ]
      * Checking for tables which need an upgrade, are corrupt or were not closed cleanly.

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







You can check php and mysql connectivity by using this script :


Testing MySQL connection with PHP script.Create the file /var/www/html/phpmysql.php then add the following line on below. Replace the password with your mysql root password.


To see script running successfully.



That's it............