Close [x]

Configure the Magento application

Edit this page on GitHub

Configure the Magento application

Now that you鈥檝e finished installing the Magento application, you need to configure it. This topic provides some recommended configuration settings for Magento; the list is not complete so watch this space.

Contents

Set up cron

cron鈥攖he UNIX task scheduler鈥攊s critical to Magento鈥檚 day-to-day operations. It schedules things like reindexing, newsletters, e-mails, sitemaps, and so on.

Immediately after finishing your Magento installation, set up a crontab for the Magento file system owner.

Prerequisites

Magento uses cron for two sets of tasks, and for each, cron can be run with a different configuration:

  • The general cron job that reindexes indexers, generates e-mails, generates the sitemap, and so on, typically runs as the PHP command-line user鈥檚 php.ini
  • Two other cron jobs are used by the Component Manager and System Upgrade utilities. Those commands must use the web server鈥檚 php.ini.

If you鈥檙e not experienced with running cron, you can run all commands with the web server鈥檚 configuration; however, we leave the decision up to you.

Find the web server configuration

To find the web server configuration, run a phpinfo.php file in your web browser and look for the Loaded Configuration File as follows:

Find the PHP binary

To display the path to your PHP binary, enter

which php

A sample result follows:

/usr/bin/php

Create the cron job

To create a cron job as the Magento file system owner, enter the following command as a user with root privileges:

crontab -u <Magento file system owner user name> -e

For example,

crontab -u magento_user -e

A text editor displays. (You might need to choose a text editor first.)

*/1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/bin/magento cron:run [> <log-file>&]
*/1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/update/cron.php [> <log-file>&]
*/1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/bin/magento setup:cron:run [> <log-file>&]

where

  • <path-to-binary> is the absolute file system path to your PHP binary
  • <ini-file-path> is the path to a php.ini file to use for the cron job
  • [> <log-file>&] is an optional but recommended string that appends cron output to a file. This is particularly useful for troubleshooting errors.

The first command (magento cron:run) reindexes indexers, send automated e-mails, generates the sitemap, and so on. Usually it鈥檚 associated with the PHP command line .ini file. The other two commands are used by the Component Manager and System Upgrade.

For example, if the PHP binary is located in /usr/bin, you installed Magento in /var/www/html/magento2, and all commands use the web server鈥檚 php.ini, enter

Example:

*/1 * * * * /usr/bin/php -c /etc/php5/apache2/php.ini /var/www/magento2/bin/magento cron:run > /var/www/magento2/var/log/magento.cron.log&
*/1 * * * * /usr/bin/php -c /etc/php5/apache2/php.ini /var/www/magento2/update/cron.php > /var/www/magento2/var/log/update.cron.log&
*/1 * * * * /usr/bin/php -c /etc/php5/apache2/php.ini /var/www/magento2/bin/magento setup:cron:run > /var/www/magento2/var/log/setup.cron.log&

Save your changes to the crontab and exit the editor.

Security settings

After installation, we recommend the following:

Enable Apache server rewrites

If you use the Apache web server, you must enable server rewrites for pages to display properly. Otherwise, you鈥檒l see pages without styles and other issues.

Section on Apache server rewrites

Server settings

This section briefly discusses settings we recommend you consider for the server on which Magento runs. Some of these settings are not directly related to Magento; these are provided as suggestions only.

Log rotation

The UNIX logrotate utility enables you to administer systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file can be handled daily, weekly, monthly, or when the log file exceeds a specified size.

For more information, see the logrotate man page or a tutorial like this one on geekstuff.

Set up iptables rules to enable various Magento services to communicate.

Whether you have one server or many, you must open ports in the firewall to enable Magento services to communicate. For example, if you use the Solr search engine with Magento Enterprise Edition (EE), you must enable it to communicate with the web server. If you have multiple web nodes, you must enable them to communicate with each other.

More information:

Security Enhanced Linux (SELinux) rules

We don鈥檛 recommend whether or not you use SELinux at all; however, if you use it, you must configure Magento services to communicate with each other similar to configuring iptables.

More information:

Set up an e-mail server

Magento requires an e-mail server. We don鈥檛 recommend a particular server but you can try any of the following:

Settings for Magento Enterprise Edition (EE) only

You can configure the following only if you use Magento EE: