Magento

Magento is an open-source eCommerce web application. This article provides steps to install Magento on a DreamHost domain.

For more information about Magento, please visit their site at:

Magento uses a large amount of server resources. Because of this, you can only install and run Magento on a VPS or Dedicated server. Running it on Shared hosting will cause the site to hit memory limits which can cause slowness and downtime.

For optimal performance (especially for larger stores), a Dedicated server or DreamCompute is recommended due to the presence of a local MySQL instance.

Before you install Magento

  1. Download Magento from their website at:

    Magento provides the option to download the installation file in a .zip, .tar, or .tar.bz2 format. .tar.bz2 is recommended since it's the smallest file to download, but any format will work.

  2. Create a phprc file under your user. You must raise the php memory_limit to at least 256MB.
  3. In your phprc file, also enable the intl extension.
  4. Create a database that will be used by Magento. View the following article for further information:
  5. Set your domain to use PHP 7.1 or higher. View the following article for further information:

Installing

  1. Upload the Magento file you downloaded to your web server via FTP.
  2. Log into your server via SSH, then decompress the file on the server.
  3. Confirm the Magento files are in your domain’s web directory.
  4. When you first visit your domain, you'll see it's throwing a 500 error. This is because of the site's .htaccess file. You must now edit that file to remove certain lines.

Editing your .htaccess file

Your .htaccess file has several lines in it mentioning IfVersion. This requires 'mod_version' to be installed on the server. Since DreamHost servers do not have this module installed, you must manually remove those lines from the .htaccess file.

You can also download the edited .htaccess file below. NOTE: This is the Magento .htaccess file for version 2.3.

  1. Open your .htaccess file via FTP or SSH.
  2. Here is an example of a block you'll see.
    <Files composer.json>
      <IfVersion < 2.4>
        order allow,deny
        deny from all
      </IfVersion>
      <IfVersion >= 2.4>
        Require all denied
      </IfVersion>
    </Files>
  3. Since DreamHost currently runs Apache version 2.2, you'll need to edit each block of code to remove the 2.4 text and <IfVersion> block. So, the above example would turn into this:
    <Files composer.json>
      order allow,deny
      deny from all
    </Files>
  4. Repeat for every block that starts with <IfVersion>.
  5. Save the file and visit your site. It should now load the Magento installation wizard.

The rest of the installation wizard is a site-level configuration and can be referenced in this page:

Troubleshooting

The site does not load after editing the .htaccess file

It's possible that after editing your .htaccess file, visiting your site displays a 500 error. Check your site's error.log file and you may see the following:

mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /home/username/example.com/vendor/magento/framework/Filesystem/Directory/Write.php on line 35

This is due to the version of Magento not being compatible with the version of PHP you're using. If you're using Magento version 2.3, make sure you're only using PHP 7.1 or 7.2. That will resolve this error message.

I can't find the installation wizard

If you’re unable to load the Magento installation wizard, you may have the installation file in another location other than the domain’s root web directory. Check to make sure the installation file is not in a subdirectory, and also make sure all files, folders, and subfolders have the correct permission.

Links don't redirect correctly

If you completed the installation and click links such as “my account”, “my wishlist”, ‘my cart”, or “about us”, and find they are not functioning correctly, you probably checked the box ‘Use Web Server (Apache) Rewrites’ during the installation wizard. To fix this, create an .htaccess file in the site's root web directory and enter the following:

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

 Login error 'Your current session has been expired'

When entering your Magento user/password, you may see the following error:

Your current session has been expired.

The following steps will resolve this:

  1. Log into your database using phpMyAdmin.
  2. In the left pane, click your database name to select it.
  3. In the top menu, click the 'SQL' tab.
  4. Enter the following command:
    INSERT INTO `core_config_data`(`path`, `value`) VALUES ('admin/security/session_lifetime',864000)
    It will look like this:
  5. Click the Go button to run it.
  6. Log into your server via SSH. Make sure you're in your website's directory.
  7. Run the following commands:
    [server]$ rm -rf var/cache/*
    [server]$ rm -rf var/page_cache/*
    [server]$ php bin/magento cache:flush
  8. Refresh your login page. You should now be able to log in.

See also

Did this article answer your questions?

Article last updated PST.