Tuesday, 13 January 2015

Setup LAMP easily on Ubuntu

In previous tutorials, we installed php, MySQL, phpmyadmin, php-modules to setup server on Ubuntu PC. All these installation was a little tricky and all was lot of commands.
Lets make our work easy with a few commands and all is done.....

LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform that uses Linux as operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.

About tasksel
It is a software installation application that is an integral part of the Debian installer and works under Ubuntu Linux too. It groups some packages by tasks and offers the user an easy way to install the packages for that task. It provides the same functionality as using conventional meta-packages. in Maverick this command dosn`t come by default, so we need to install it first before to perform the LAMP installation.

Open terminal and Type the command :
sudo apt-get install tasksel
 Now to install LAMP, type the taskel command in terminal :
sudo  tasksel
 And select LAMP Server:

During the installation you will be asked to insert the mysql root password



Now check if php is working :
sudo gedit /var/www/info.php
 and add
<?php
phpinfo();
?>
 save and exit

Restart apache2
sudo /etc/init.d/apache2 restart
OR
sudo service apache2 restart 
 Now open browser and type :
http://localhost/info.php

To full manage your lamp Server database, install phpmyadmin

Install phpMyAdmin

To Install phpMyAdmin on server, follow this tutorial...

Install phpMyAdmin on Ubuntu

In Previous Tutorial, you learned how to Setup LAMP Server on Ubuntu. Now, You have a working server on your Ubuntu PC. Lets do some work around phpMyAdmin.

If you have missed previous tutorial on How to Setup LAMP Server on Ubuntu. Follow This Link:
LAMP Server on Ubuntu : http://www.netpuppet.tk/2015/01/lamp-server-on-ubuntu.html
About phpMyAdmin
phpMyAdmin is an free web software to work with MySQL on the web—it provides a convenient visual front end to the MySQL capabilities.

Setup
Before working with phpMyAdmin you need to have LAMP installed on your server. If you don't have the Linux, Apache, MySQL, PHP stack on your server, you can find the tutorial for setting it up here.

Install phpMyAdmin
The easiest way to install phpmyadmin is through apt-get:
Open Terminal and Type :
sudo apt-get install phpmyadmin apache2-utils
 During the installation, phpMyAdmin will walk you through a basic configuration. Once the process starts up, follow these steps:

  • Select Apache2 for the server
  • Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
  • Enter your MySQL password when prompted
  • Enter the password that you want to use to log into phpmyadmin
After the installation has completed, add phpmyadmin to the apache configuration.
sudo nano /etc/apache2/apache2.conf
 Add the phpmyadmin config to the file.
Include /etc/phpmyadmin/apache.conf

 Restart apache:
sudo service apache2 restart

 You can then access phpmyadmin by going to:
http://localhost/phpmyadmin
 The screen should look like this


LAMP Server on Ubuntu

Are You a web developer ? This tutorial is for you. Lets learn how to build a server on Ubuntu for testing our websites before loading on internet server.

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. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

1. Install Apache
To install Apache you must install the Metapackage apache2. This can be done by running the following command.
sudo apt-get install apache2

2. Install MySQL
To install MySQL you must install the Metapackage mysql-server. This can be done by running the following command.
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 the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.

Once you have installed MySQL, we should activate it with this command:
sudo mysql_install_db
Finish up by running the MySQL set up script:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password.
Type it in.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y                                          
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...

3. Install PHP
To install PHP you must install the Metapackages php5 and libapache2-mod-php5. This can be done by running the following command.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
After you answer yes to the prompt twice, PHP will install itself.
It may also be useful to add php to the directory index, to serve the relevant php index files:
sudo gedit /etc/apache2/mods-enabled/dir.conf
Add index.php to the beginning of index files. The page should now look like this:
<IfModule mod_dir.c>
          DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

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.
apt-cache search php5-
Terminal will then display the list of possible modules. The beginning looks like this:
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-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-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
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-auth-pam - A PHP5 extension for PAM authentication
[...]
Once you decide to install the module, type:
sudo apt-get install <name of the module>
You can install multiple libraries at once by separating the name of each module with a space.

Restart Server
Your server should restart Apache automatically after the installation of both MySQL and PHP. If it doesn't, execute this command.
sudo /etc/init.d/apache2 restart
OR
sudo service apache2 restart

Check Apache
Open a web browser and navigate to
http://localhost/
You should see a message saying It works!

Check PHP
You can check your PHP by executing any PHP file from within /var/www/. Alternatively you can execute the following command, which will make PHP run the code without the need for creating a file .
Although LAMP is installed, we can still take a look and see the components online by creating a quick php info page

To set this up, first create a new file:
sudo nano /var/www/info.php
Add in the following line:
<?php
phpinfo();
?>
Then Save and Exit.

Finish up by visiting your php info page: http://localhost/info.php


 Congratulations, you have just Installed a Ubuntu LAMP Server!

Install phpMyAdmin


Wednesday, 7 January 2015

Customize Login Screen in Ubuntu

Are you an Ubuntu Lover ? Then this is for you.

By default Ubuntu comes with unity login screen having password box to the left of screen and and some ugly colored background.

Here I am not going to guide you how to just change background and remove dots only. But I will take you beyond this and make your login screen more decorative and attractive.

In default unity login, it is not possible to change to login position from left to center, right or any other point on the screen.

To make our work ease you need to install lightdm. Don't worry It's safe and will not harm if followed instructions carefully.

Lets Begin the Journey...... 

1. Install lightdm

lightdm is a display manager used default in Xubuntu, Kubuntu, etc. but it's not included in Ubuntu
    
Open Terminal : 
ctrl+alt+T
Type these commands :

sudo add-apt-repository ppa:lightdm-gtk-greeter-team/stable
sudo apt-get update
sudo apt-get install lightdm-gtk-greeter

Thats it.... lightdm is installed

2. Install LightDM GTK+ Greeter Setting GUI 

This is a small program written in python which lets you modify various LightDM GTK+ Greeter settings, such as the theme, font, background, window position and more, settings which otherwise can only be set by modifying the greeter configuration files.

In terminal window type :
sudo add-apt-repository ppa:kalgasnik/ppa
sudo apt-get update
sudo apt-get install lightdm-gtk-greeter-settings
Now search for lightdm in unity and change Background color in the Appearance.
Please, don't forget to Press Reload Button on the Bottom-Left after Save.

Restart your PC to see the changes made. You will be introduced with a new login screen having a drop down menu which have your username, Guest and Others in the list to select.

3. Real game Begins now....

3.1 Changing Background Image

Lets do some more fun.
Open the LightDM GTK+ Greeter Setting from unity.
On Background select image and choose a picture from the directory on your computer.

[Note : It will be better to change image resolution to your PC's screen resolution in photoshop or any other photo editing software or online]

3.2 Moving position of Login box on screen 
 
Now move to Window position Tab.
Click on the dots in the center image where you want to place the login box.
You can also adjust position by changing Horizontal and Vertical padding.

Till now, we have decorated login screen.
Let's do some hacking part.

3.3 Disabling Guest-Login
 
In Ubuntu 14.04 the .conf file to be edited has been moved to /usr/share/lightdm/lightdm.conf.d from /etc/lightdm/

run these commands :

sudo gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
add line :

allow-guest=false
3.4 Enable Manual login

since, in versions earlier than 14.04 .conf file is located in /etc/lightdm/ directory which has been moved to /usr/share/lightdm/lidhtdm.conf.d/ , we need to create a lightdm.conf file in /etc/lightdm directory

run this command :

sudo gedit /etc/lightdm/lightdm.conf
add lines :

[SeatDefaults]
greeter-show-manual-login=true
greeter-hide-users=true
You will get login box as :



4. Thats it.... Now, restart your pc and see the change.

Here is what I have done...


[Note : This works 100% fine in Ubuntu 14.04 LTS. I have not tested it on versions below 14.04. If it works for you or have any error please comment below]
Powered by Blogger.