Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Dec 272010
 

Change the access file name (i.e. .htaccess) in Apache

Answer:

If you have not set the AllowOverride to None in your Apache's configuration, Apache will read the file .htaccess on every request. If you want to use a file name other than .htaccess, you can set using the AccessFileName directive

AccessFileName .acl

Then Apache will read the file .acl instead, remember to restart your Apache to take effect.

Dec 172010
 

How to change the nginx log format?

Answer:

Firstly, you need to define a valid log format for nginx, e.g.

log_format foo '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent"';

Then, you need to link that format with your log file:

access_log /var/logs/nginx-test-access.log foo;

Dec 142010
 

Display the top 10 processes used up the most of the memory

Answer:

The following command display the most top 10 processes used up the most of the memory in your Linux system.

Example:

# ps aux | sort -nk +4 | tail

www-data 27972  0.0  2.8 253896 14916 ?        S    13:10   0:00 /usr/sbin/apache2 -k start
www-data 27725  0.0  2.9 254028 15572 ?        S    12:52   0:00 /usr/sbin/apache2 -k start
www-data 27912  0.0  2.9 253896 15660 ?        S    13:06   0:00 /usr/sbin/apache2 -k start
www-data 27946  0.0  2.9 253764 15492 ?        S    13:08   0:00 /usr/sbin/apache2 -k start
root      2710  0.0  3.1 252996 16444 ?        Ss   Dec08   1:20 /usr/sbin/apache2 -k start
www-data 27885  0.0  3.4 253508 18152 ?        S    13:05   0:00 /usr/sbin/apache2 -k start
www-data 27892  0.1  6.7 261748 35472 ?        S    13:06   0:00 /usr/sbin/apache2 -k start
www-data 27975  0.3  7.0 263036 37128 ?        S    13:10   0:00 /usr/sbin/apache2 -k start
www-data 27964  0.7  8.2 268532 43452 ?        S    13:09   0:00 /usr/sbin/apache2 -k start
mysql     2480  0.4  8.7 223920 46096 ?        Sl   Dec08  21:07 /usr/sbin/mysqld 

Since the apache2 was configured to run in the prefork mode, so you see multiple apache processes there.

Aug 142010
 

Enable gzip compression in Nginx

Answer:

Enabling gzip compression for text based output such as HTML can greatly improve the response of user.

If you are using nginx, it is easy by adding the following lines in your nginx.conf

gzip  on;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types text/plain text/html text/css application/json application/x-javascript text/javascript text/xml application/xml;