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.

Linux Ask!

Dec 302010
 

Turn off directory listing in Apache

Answer:

If you web site's directory without a valid default index page, e.g. index.html, Apache might list all files inside the directory. If you want to turn off, do the following.

Add the following lines to the Apache configuration (httpd.conf)

Options All -Indexes  

Restart Apache to take effect

# apachectl -k graceful

Dec 292010
 

Enable MySQL binary log (bin log)

Answer:

The MySQL binary log contains the changes to the database in binary log format. They are useful for

  1. Database recovery
  2. Replication

To enable it, edit the MySQL configurations, e.g. /etc/my.cnf

..
log-bin
..

Don't forget to restart MySQL to take effect.

# /sbin/service mysqld restart

Dec 282010
 

Change the PHP's maximum upload file size

Answer:

The default maximum upload file size in PHP is only 2MB. If you want to change it, you need to edit the php.ini

vi /etc/php.ini

Locate and set (100M in the following example)

memory_limit = 100M;
post_max_size = 100M;
upload_max_filesize = 100M;

Try it with the number you need. (You might need to use a large value in post_max_size and memory_limit if you want to upload a file which is exactly 100M in size)

Also, remember to restart web server such as Apache if needed.

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 262010
 

Display timestamp information in command history

Answer:

When using the history command, it only shows the command number and the command itself. But sometimes it is useful to know when this command was executed, i.e. the timestamp. To do so, following the instructions below:

# export HISTTIMEFORMAT='%F %T '

Then type history again

# history
..
 260  2010-12-23 19:22:07 ls
 261  2010-12-23 19:22:07 pwd
...

That's all.