Mail with attachment from Shell

Today, for a specific need, I had to work with logwatch. After setting up logwatch, I needed to check the logwatch reports. But I can’t wait for it to mail me at next mailing time. But I can generate the report to see on screen by

logwatch –print

But it was too big! So, I redirected the output to a file by running:

logwatch –print > logwatch.txt

But still I am not comfortable reading such a big file from shell. So I thought to mail it. I wondered how! If I am not wrong, mail command can’t send attachment. Even I did not found anything in manual of mail command. So, started googling. I came to know about Mutt. After using it I see it is awesome and very easy. Continue reading →

Easy Control Nginx!

Nginx

Nginx

Recently I am trying to learn managing nginx web server. Most probably it is going to take the place of Apache or at least seat beside Apache. The main benefit Nginx is claimed to be low memory footprint.

So far I have configured three VPS with nginx (also mysql & php). But every time I felt uneasy to start and stop the service as it can’t be started or stopped as ordinary service call.

For example:

To start apache/httpd we write:

service httpd start

But to start Nginx we have to write:

/usr/local/nginx/sbin/./nginx

[I assume that Nginx is installed in default directory]

Again to stop apache, we write:

service httpd stop

But in case of Nginx:

kill -9 `cat /usr/local/nginx/logs/nginx.pid`

or

killall -9 nginx

Today I thought to make it a bit easier. So after mining the internet, I have made a small script to take care of start, stop, restart and check the status of Nginx. I am new to shell scripting.

How to implement it?

  1. I expect your Nginx installation is completed successfully and you can start/stop the server using the earlier methods.
  2. Download this file
  3. Store the file in /sbin/ as nginx. So that path of this file will be /sbin/nginx
  4. Chmod it to 744 by calling:
    chmod 744 /sbin/nginx
  5. You are done.

Now to start the server:

nginx start

Stopping the server:

nginx stop

Restarting the server:

nginx restart

Checking Status:

nginx status

Hope you like it :).

So, any suggestion is

Yum groupinstall may save your hours!

Today I have purchased another new VPS to play with nginx web server. After getting the login info, I tried to compile the nginx source. But I found that no development libraries were installed. So I started to install one by one:

yum install gcc

yum install glibc

yum install make

and so on. [Note: these can be run as yum install gcc glibc make this way]

anyway, each time I run the configure script, I find something is missing. Later, groupinstall splashed in my mind. Though I know about its functionalities, I have never used it before. But I failed trying like:

yum groupinstall development

or

yum groupinstall development-tools

etc.

Later I found the trick to know the groups name.

yum grouplist will show all available groups name. After hit the return key you will get a list like the following:

Administration Tools
Compatibility Arch Support
Editors
Development Tools
GNOME Desktop Environment
GNOME Software Development
Games and Entertainment
Graphical Internet
Graphics
Mail Server

…..

You should see them in two categories. “Installed” and “Available”. You know what they mean.

Now we know the all available groups name. So its time to execute. I needed the development libraries. So I run

yum groupinstall “Development Tools”

You should type the name as shown in the list including the quotation marks. It will install everything on that group.

Be careful before using it. It may install many unnecessary things. Use it where it is really necessary.

PHP_SELF is empty!

Last two days, I am playing or learning to play with nginx web server. I have heard some reputation about it and saw some performance chart in the web. I liked it for its, as claimed, extremely low memory footprint for one of my small VPS.

After reading some tutorial in Projanmo Forum, I am successfully configured nginx, with with fastcgi, php-fpm, mysql etc. When I visit the website, I found some problems. Some section were not working. Later I found, where I used $_SERVER[‘PHP_SELF’] were not not working. Later investigating the phpinfo(); I have seen that some global php variables are empty. I found nothing on net. Later alamgir bro, helped to sort out. In fact the whole tutorial is contributed by him.

Solving this issue is real easy. Just add the following the in your nginx php configuration section.

include        fastcgi_params

The changed codes may look like: [copied directly from his mail]

location ~ \.php$ {
root           /www;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;

include        fastcgi_params;  #newly added

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

……….

……….

hope this will save your time :-).

Fedora Transformation Pack

Just few minutes ago I came to know about Fedora Transformation Pack. Earlier, I did use Vista Transformation Pack which is used to give Windows XP some Vista look. But this pack gives a different looks. It gives you Fedora look hence Linux look.

If you are a Fedora/Linux fan you may try it.

The download link is here:
http://download1us.softpedia.com/dl/75952093d54a212d59fe316d40162c3a/47db9b7e/100082328/software/system/FedoraTP1.0.zip