Monday, July 23, 2012

Set index.php as default page

I was programming a Web app and I noticed that always insert address of Web app, I had to type "www.mywebapp.com/index.php" to show up a web page. If I just type the next address "www.mywebapp.com", the Web server (Apache) list the directories and some files.

I would rather type "www.mywebapp.com" and same time the Web server show up the index.php. But how can I do that? Just follow the next steps:

  1. Open notepad and write the next statement "DirectoryIndex index.php"
  2. Save file as
    • Write name of file as ".htaccess"
    • Change type of file from " Text file (*.txt)" to "All files (*.*)"

Note: You must save the file on the same folder where is "index.php". If you don't save on the same folder, it will not work correctly.

Conclusion: The DirectoryIndex command allows specify a default page to display.

Monday, July 9, 2012

How to import a MySQL dump file into a Database

To import MySQL dump file into a database you must have a MySQL command line shell.

Step #1: Make sure your database is already created. If database is not created yet, then you have to create one database. For example:

->mysql -h localhost -u root -p;
(enter your password)
->CREATE SCHEMA IF NOT EXISTS 'database_name';
->exit;

Note

You can replace "localhost" by an IP address (e.g. 192.168.1.88).

Step #2: Type the next command to import MySQL dump file into a database.

->mysql -h localhost -u root -p database_name < file.sql
(enter your password)

Voilá! Now you have a database with all data filled.