When you install Magento, you can start with an empty database or a database with some sample products and configurations. For our development environment, the best approach is to start with the sample data because we can start using Magento directly after installation.
For a new webshop, it is recommended to start with an empty database and do the configuration yourself. To install Magento, we need the following data:
The Magento code
The sample data
You can download Magento and the sample data from Magento's website (http://www.magentocommerce.com/download). Download the latest Full release and the Sample data. The recipes of this book are based on the Magento Version 1.8.1.0. For the sample data, you can use the 1.6.1.0 Version.
The following steps show you how to install a clean Magento webshop with sample data:
Extract the code in the appropriate folder of our web server. In our case, this is
/var/www/magento-dev.local/public
. Take a look at the folder structure by running thels -la
command in the site's root folder. We have to take care that the hidden files are included in the folder:ls -la drwxrwxr-x . drwxrwxr-x .. -rwxrw-r-- .htaccess -rw-rw-r-- .htaccess.sample -rw-rw-r-- api.php drwxrwxr-x app -rw-rw-r-- cron.php -rw-rw-r-- cron.sh drwxrwxr-x downloader drwxrwxr-x errors -rw-rw-r-- favicon.ico -rw-rw-r-- get.php -rw-rw-r-- .htaccess -rw-rw-r-- .htaccess.sample drwxrwxr-x includes -rw-rw-r-- index.php -rw-rw-r-- index.php.sample -rw-rw-r-- install.php drwxrwxr-x js drwxrwxr-x lib -rw-rw-r-- LICENSE_AFL.txt -rw-rw-r-- LICENSE.html -rw-rw-r-- LICENSE.txt -rw-rw-r-- mage drwxrwxr-x media -rw-rw-r-- php.ini.sample drwxrwxr-x pkginfo -rw-rw-r-- RELEASE_NOTES.txt drwxrwxr-x shell drwxrwxr-x skin drwxrwxr-x var
Tip
In Linux, hidden files or folders start wit a dot (.), such as the
.htaccess
file. The-a
option of thels
command that we used shows all the files and folders, including the hidden ones. It is important to see that the.htaccess
file is in the directory because this file contains the configuration for URL rewrites and other server configurations.When you extract the sample data archive, you see a media folder and a SQL file. The SQL file contains the database, the media folder, and the images. To install the media folder, merge this folder with the site's root media folder.
To install the database, you have to run the following commands:
To create the database, run the following commands:
mysql -u root -p create database magento_dev; exit;
To import the SQL file, run the following commands:
mysql -u <<username>> -p magento_dev < "path_to_sample_data.sql"
Tip
To avoid permission problems, ensure that all files and folders have the right permissions. For security reasons, it is recommended that all files have just enough permissions so that only the right users can access the right files. When you give all the rights (777), you don't have permission problems; but, every user on the server can read, write, and execute every file of your application.
The next step is to run the Magento installation wizard. Go to the site's URL and the installer will be displayed as shown in the following screenshot:
Continue with the installation process by accepting the terms and conditions.
On the next screen, choose the correct language, locale, and currency for your store.
On the Configuration page, fill the form with the right data:
Database Type: Enter
MySQL
in this field.Host: Enter
localhost
in this field.Database Name: Enter
magento_dev
(your Magento database name) in this field.User Name: Enter
root
(your Magento database username) in this field.User Password: Enter
root
(your database user password) in this field. It is possible to leave this empty.Tables Prefix: Leave this field empty (if filled, all tables will have the prefix that is entered here).
Base URL: Enter
http://magento-dev.local/
(the URL of your webshop) in this field.Admin Path: Enter
admin
(the path to the backend) in this field.Skip Base URL Validation Before the Next Step: This check box must be unchecked (if checked, the wizard will check for a valid URL when processing this form).
Use Web Server (Apache) Rewrites: This check box must be unchecked.
Submit the form and continue to the next step. In this step, you can configure the admin account. Fill in the right data and remember the login and password, because this is required to manage the store. Leave the encryption key empty.
After submitting this form, the installation wizard terminates. The setup is complete. You can now visit your store and enter the backend with the username that you have created in the installation wizard.
We just created a fully functional Magento store. Technically, you can start selling products.
We have started with the sample data. The SQL file that we inserted in the database contains all the data for the sample webshop. When you want to create an empty shop, you can start with an empty database.
When installing a new shop, always follow the installer. The installer creates the app/etc/local.xml
file and installs the values that you have set in the installer. These values are currency, timezone, backend user, and so on. The installer will show up when there is no local.xml
file in the app/etc/
folder. In all other cases, the webshop will show up.
With a complete local.xml
file in the app/etc
folder, you can install Magento. However, this is not recommended because you don't have a backend user and the other configurations.