Search This Blog

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, July 24, 2014

install Nginx PHP mongodb ubuntu

Install prerequisites
apt-get update
apt-get install php5-cli php5-common php5-cgi php5-curl php5-fpm php5-json php5-mcrypt php5-dev php-pear php-apc
Enable Mongo
pecl install mongo
echo "extension=mongo.so" >> /etc/php5/fpm/php.ini
Install MongoDB
apt-get install mongodb mongodb-server
Restart Services
service nginx restart
service php5-fpm restart
done

Thursday, April 19, 2012

Linux Directory layout

Linux Directory layout

A quick ‘ls‘ command will show you the directory structure of any linux system. Just go to the root directory, ‘cd /‘ and type ‘ls’. In my current system, Ubuntu 8.10 I have:

bin

Bin contains the system binary files that are essential for general operation of your computer. These exectuable files are the next line after the system kernel. Withtout these you can’t do a whole lot of anything on your computer. Some of these include:
  • cp – Copy files to and from
  • ls – Get a directory listing, remember we used this above
  • bash – A popular Linux CLI (shell)

dev

If you are used to other operating systems this will be weird for you. As everything in Linux devices are represented as a directory. This makes it easier for other programs to interact with them. For example mount.
You can use the system binary mount in the /bin folder to interact with a removable hard drive for example.

lost+found

If you have a system crash and the Linux file system checker (fsck) recovers corrupt files they are placed here.

opt

Opt is reserved for additional software you install; although, most providers don’t use it. This is kind of like ‘Program Files‘ for linux.

sbin

Sbin is similar to /bin with the exception that these ready to run binaries are reserved for root users. That is they typically will only work when executed by root or sudo. Examples would include:
  • mke2fs
  • ifconfig
  • fdisk

tmp

Tmp is a temporary storage folder. Anything that is to be temporarily stored goes here. It is recommended that you don’t delete these manually. If you want to delete them you usually add this to boot up or shutdown procedure since they can contain useful information for programs that are already running.

boot

This folder contains only the files that are absolutely necessary to get a basic Linux system up and going. This folder is not used for programs to run on startup or other user scripts. This folder usually contains Grub information and the Linux kernel.

etc

This folder is the config folder for your entire operating system. Almost everything about configuring your system can be done in here. The general rule of thumb is that these files are static and text based. No binaries should be placed in this folder.
Common config files in here are:
  • /etc/X11 – For configuring X (gui)
  • /etc/apt/sources.list – Configuring apt for Debian based systems
  • /etc/cups – Printer configuration
  • /etc/fstab – Device mounting
  • /etc/httpd – Apache webserver

Media

Traditionally all mounts were stored in the /mnt directory but out of controversy of where to stored removable mounts this directory was born. /media should be used to store mounts for removable devices only, like:
  • CD-Rom
  • DVD-Rom
  • Floppy
  • Flash Disks

proc

Proc is a special virtual directory like /dev that contains process information. It contains runtime system info like: system memory, devices mounted, hardware configuration, etc.

srv

Srv is a serve folder. It holds site specific data to be served by the system for protocols such as, ftp, rsync, www, cvs etc. To be compliant distributions include this folder but I have not seen it used much.

usr

Usr houses all the binaries, documentation, libraries, and header files for all the user applications. Most user binaries will be installed into this folder making this one of the largest folders in the Linux directory.

cdrom

CD-Roms can be mounted to this folder but it is not in the official Linux Filesystem Hierarchy. CD-Roms should be mounted under /media.

home

Home is where you will store all user specific documents and settings. This is similar to Windows, “Documents and Settings”. On most Linux distributions /home will contain a directory with each user’s name or group of users. e.g. /home/mark /home/guests.

lib

Lib contains system library binaries that are required to run the system. In Windows this would be the system folder with .dlls. Only in Linux it is represented by ‘.so‘.

mnt

According to FSSTND version 2.3, ” This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.”
I think of this directory as the place to mount fixed hard drives that I mount with the fstab file, but as described in FSSTND it is primarily for temporary mounts.

root

Root is the “home” directory for root. If this directory doesn’t exist it defaults back to ‘/’. Hence the username root.

sys

This is kinda like /proc it is used for plug and play configuration.

var

This stands for variable. This stores all the files that vary as the system runs. Things like log files, backups, mail, cache, etc..

Thursday, December 2, 2010

CRON

we can use any of these commands though, you first need to understand the crontab itself. Each line in a crontab needs to specify five time fields in the following order: the minutes (0-59), hours (0-23), days of the month (1-31), months (1-12), and days of the week (0-7, Monday is 1, Sunday is 0 and 7). The days of the weeks and months can be specified by three-letter abbreviations like mon, tue, jan, feb, etc. Each field can also specify a range of values (e.g. 1-5 or mon-fri), a comma separated list of values (e.g. 1,2,3 or mon,tue,wed) or a range of values with a step(e.g. 1-6/2 as 1,3,5).
That sounds a little confusing, but with a few examples, you will see that it is not as complicated as it sounds.
Code Listing 3.8: Examples
# Run /bin/false every minute year round
*     *     *     *     *        /bin/false

# Run /bin/false at 1:35 on the mon,tue,wed and the 4th of every month




35    1     4     *     mon-wed  /bin/false

# Run /bin/true at 22:25 on the 2nd of March
25    22    2     3     *        /bin/true

# Run /bin/false at 2:00 every Monday, Wednesday and Friday




0     2     *     *     1-5/2    /bin/false
Note: Notice how you have to specify specific days of the week and days of the month before they are combined. If you have * for only one of them, the other takes precedence, while * for both just means every day.
To test what we have just learned, let's go through the steps of actually inputting a few cron-jobs. First, create a file called crons.cron and make it look like the this:
Code Listing 3.9: Editing crons.cron
$ nano crons.cron
#Mins  Hours  Days   Months  Day of the week
10     3      1      1       *       /bin/echo "I don't really like cron"




30     16     *      1,2     *       /bin/echo "I like cron a little"
*      *      *      1-12/2  *       /bin/echo "I really like cron"
Now we can add that crontab to the system with the "new command" from the table above. 

4.  Using cronbase
As mentioned earlier, all of the available cron packages depend on sys-process/cronbase. The cronbase package creates /etc/cron.{hourly,daily,weekly,monthly}, and a script called run-crons. You might have noticed that the default/etc/crontab contains something like this:
Code Listing 4.1: Default system crontab
*/15 * * * *     test -x /usr/sbin/run-crons && /usr/sbin/run-crons
0  *  * * *      rm -f /var/spool/cron/lastrun/cron.hourly
0  3  * * *      rm -f /var/spool/cron/lastrun/cron.daily




15 4  * * 6      rm -f /var/spool/cron/lastrun/cron.weekly
30 5  1 * *      rm -f /var/spool/cron/lastrun/cron.monthly
To avoid going into much detail, we can just assume that these commands will effectively run your hourly, daily, weekly and monthly scripts. This method of scheduling cron-jobs has some important advantages:
  • They will run even if your computer was off when they were scheduled to run
  • It is easy for package maintainers to place scripts in those well defined places
  • You know exactly where your cron-jobs and your crontab are stored, making it easy for you to backup and restore this part of your system
5.  Final Notes
If you're having problems getting cron to work properly, you might want to go through this quick checklist.
  • Is cron running? Run ps ax | grep cron and make sure it shows up!
  • Is cron working? Try: * * * * * /bin/echo "foobar" >> /file_you_own and make sure it works
  • Is your command working? Try: * * * * * /bin/foobar > /file_you_own 2>&1 and look for errors in /file_you_own
  • Can cron run your job? Check the cron log, usually /var/log/cron.log or /var/log/messages for errors
  • Are there any dead.letters? cron usually sends mail when there's a problem; check your mail and also look for ~/dead.letter.
Remember, each cron package is different and the range of features varies greatly. Be sure to consult the man pages for crontab, fcrontab or anacrontab, depending on what you use.

How to compile and install a new Linux kernel

Be especially cautious when messing around with the kernel. Back up all of your files, and have a working bootable recovery floppy disk or CD-ROM nearby. Learn how to install a kernel on a system that doesn't matter. You've been warned. This is obviously a very short guide; only use in conjunction with a more thorough guide such as The Linux Kernel HOWTO
1. Download the latest kernel from kernel.orgThe kernel comes as a 20 to 30 MB tar.gz or tar.bz2 file. It will decompress to about 200 MB and during the later compilation you will need additional space.
Example:
wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.gz
tar zxvf linux-2.4.19.tar.gz
cd linux-2.4.19

2. Configure the kernel optionsThis is where you select all the features you want to compile into the kernel (e.g. SCSI support, sound support, networking, etc.)
make menuconfig
* There are different ways to configure what you want compiled into the kernel; if you have an existing configuration from an older kernel, copy the old .config file to the top level of your source and use make oldconfig instead of menuconfig. This oldconfig process will carry over your previous settings, and prompt you if there are new features not covered by your earlier .config file. This is the best way to 'upgrade' your kernel, especially among relatively close version numbers. Another possibility is make xconfig for a graphical version of menuconfig, if you are running X.
3. Make dependenciesAfter saving your configuration above (it is stored in the ".config" file) you have to build the dependencies for your chosen configuration. This takes about 5 minutes on a 500 MHz system.
make dep

4. Make the kernelYou can now compile the actual kernel. This can take about 15 minutes to complete on a 500 MHz system.
make bzImage
The resulting kernel file is "arch/i386/boot/bzImage"
5. Make the modulesModules are parts of the kernel that are loaded on the fly, as they are needed. They are stored in individual files (e.g. ext3.o). The more modules you have, the longer this will take to compile:
make modules

6. Install the modulesThis will copy all the modules to a new directory, "/lib/modules/a.b.c" where a.b.c is the kernel version
make modules_install

* In case you want to re-compile...If you want to re-configure the kernel from scratch and re-compile it, you must also issue a couple "make" commands that clean intermediate files. Note that "make mrproper" deletes your .config file. The complete process is:
make mrproper
make menuconfig
make dep
make clean
make bzImage
make modules
make modules_install

* Installing and booting the new kernelFor the remainder of this discussion, I will assume that you have LILO installed on your boot sector. Throughout this process, always have a working bootable recovery floppy disk, andmake backups of any files you modify or replace. A good trick is to name all new files with -a.b.c (kernel version suffix) instead of overwriting files with the same name, although this is not shown in the example that follows.
On most Linux systems, the kernels are stored in the /boot directory. Copy your new kernel to that location and give it a unique name.
Example:
cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.19
There is also a file called "System.map" that must be copied to the same boot directory.
cp System.map /boot
Now you are ready to tell LILO about your new kernel. Edit "/etc/lilo.conf" as per your specific needs. Typically, your new entry in the .conf file will look like this:
image = /boot/vmlinuz-2.4.19
  label = "Linux 2.4.19"
Make sure the image points to your new kernel. It is recommended you keep your previous kernel in the file; this way, if the new kernel fails to boot you can still select the old kernel from the lilo prompt.
Tell lilo to read the changes and modify your boot sector:
lilo -v
Read the output carefully to make sure the kernel files have been found and the changes have been made. You can now reboot.
Summary of important files created during kernel build:
.config (kernel configuration options, for future reference)
arch/i386/boot/bzImage (actual kernel, copy to /boot/vmlinuz-a.b.c)
System.map (map file, copy to /boot/System.map)
/lib/modules/a.b.c (kernel modules)

Installation commands for LAPP

#! /bin/bash
cd /usr/local
tar -xvjf src/postgresql-8.2.4.tar.bz2
cd postgresql-8.2.4/
./configure
gmake
gmake install
adduser -M postgres
groupadd apache
adduser -M -g apache apache
mkdir /usr/local/pgsql/data
chown postgres:postgres /usr/local/pgsql/data
su -c '/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data' postgres
su -c '/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1&' postgres
su -c '/usr/local/pgsql/bin/createuser sundar' postgres
cp contrib/start-scripts/linux /etc/init.d/postgresql
chmod a+x /etc/init.d/postgresql
cp /usr/local/postgresql-8.0.3/contrib/reindexdb/reindexdb /usr/local/pgsql/bin
chmod a+x /usr/local/pgsql/bin/reindexdb
cd /etc/init.d
chkconfig --add postgresql
chkconfig postgresql on
/etc/init.d/postgresql restart
sed -i '/\/usr\/local\/pgsql\/bin/!s/\(^PATH\) *=\(.*\)/\1=\/usr\/local\/pgsql\/bin\:\2/' /etc/skel/.bash_profile
cp /etc/skel/.bash_profile /home/sundar
echo Postgresql Installation Completed

cd /usr/local            
tar -xvzf src/apache_1.3.37.tar.Z
tar -xvjf src/php-5.2.5.tar.gz
cd apache_1.3.37/
./configure --enable-module=so
gmake
gmake install
echo Apache Installation Completed
cd ../php-5.2.5/
./configure --with-pgsql --with-apxs=/usr/local/apache/bin/apxs --with-curl=/usr --enable-calendar --with-curl --enable-dba --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-ttf --with-freetype-dir --enable-gd-native-ttf --with-mime-magic --with-zlib-dir --enable-soap --with-regex=php
gmake
gmake install
cp /usr/local/src/httpd.conf /usr/local/apache/conf/httpd.conf
cp /usr/local/src/httpd /etc/init.d/httpd

cd /etc/init.d
chkconfig --add httpd
chkconfig httpd on
/etc/init.d/httpd restart
cp /usr/local/src/phpinfo.php /usr/local/apache/htdocs
echo PHP Installation Completed

Thursday, June 17, 2010

Apache Solr Installation and Configuration

Installation


1. Download Apache Solr Package (http://www.apache.org/dyn/closer.cgi/lucene/solr/)

2. In shell enter “tar –xvzf apache-solr-x.x.x.tgz” this step will create a folder apache-solr-x.x.x

3. Rename the folder for ease of use “mv apache-solr-x.x.x apache-solr”

4. Install JDK (requires > 1.6.0) can download from sun downloads(http://java.sun.com/javase/downloads/widget/jdk6.jsp)

5. “cd apache-solr/example/”

6. Start the servlet “Java –jar start.jar”, Long list of messages will appear at the end you can see message as follows : INFO: Started SocketConnector @ 0.0.0.0:8983

7. Check for errors in java if so please correct it and restart the server. To Stop the server use “CTRL+C”

8. If everything goes fine you should see a screen as below in your browser


Thursday, March 18, 2010

Install Tamil font in kubuntu

Install tamil font package 

 gt@gt-laptop:~$ sudo apt-get install language-support-ta

Install Scim (Input language can be changed using system tray flag icon)


sudo apt-get install scim

Default Font directory





cd /usr/local/share/fonts/


Create Dir 

mkdir truefonts

Copy tamil fonts here after downloading 

Update new fonts 

sudo mkfontscale && sudo mkfontdir && sudo fc-cache

Restart X server or reboot system

Done
....

Thursday, February 4, 2010

Add Repo to the Kubuntu Source list

Open file /etc/apt/sources.list on vi or any text editor with sudo

ex sudo vi /etc/apt/sources.list

Add the following lines at the end of the file

'deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main'
'deb-src http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main'

Run this command on konsole

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 247510BE

open start->system settings->computer administration->add or remove software
on the search box type firefox-X.x

Select the package from the list below to install and enjoy :)

Wednesday, February 3, 2010

Reliance netconnect for linux(Kubuntu)

etc/wvdial.conf

[Dialer Defaults]
Modem = /dev/ttyUSB0
Username = 9345237940[replace with ur no]
Phone = #777
Password = 9345237940[replace with ur no]
New PPPD = yes
Stupid mode = yes

wvdial as root