For hide index.php in Magento,we should start the URL rewrite function.
1.Start the module mod_write
a2enmod rewrite
or
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
2.Edit Apache configure file defaut and make Apache can recongnise file .htaccess under web root document
AllowOverride none to AllowOverride all
3.Edit .htaccess <IfModule mod_rewrite.c>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
4.Goto magento admin page,and click system->configuration->web->search engines optimization ,set "Use Web Server Rewrites" to "Yes".
Click system->Index Management,.select all and choose "Reindex Data".
5.restart apache