Magento 2.4+
It is no longer possible to install Magento (versions 2.4+) on DreamHost servers since Magento now requires Elasticsearch to be installed on the server in order to function.
If you would like to run Magento 2.4+ on a DreamHost server, the only option would be to upgrade to a Dedicated Server. You could then manually install Elasticsearch and Magento.
Please note that DreamHost support is unable to assist with this type of custom installation.
The instructions below are for older versions of Magento and should only be used as a general reference.
Overview
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
- 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.
- Create a phprc file under your user. Raise the php memory_limit to 756MB, and increase the max_execution_time. Here is what your phprc file should look like:
max_execution_time = 5000 memory_limit = 756M
- Create a database that will be used by Magento. View the following article for further information:
- Set your domain to use PHP 7.4. View the following article for further information:
Installing
- Upload the Magento file you downloaded to your web server via FTP.
- Log into your server via SSH, then decompress the file on the server.
- Confirm the Magento files are in your domain’s web directory.
- From your site's web directory, run the following command to start the installation process:
[server]$ bin/magento setup:install --db-host=mysql.example.com --db-name=example_magento --db-user=magentodb --db-password=example123 --base-url=https://example.com/ --backend-frontname=example_admin --admin-firstname=Admin --admin-lastname=Example --admin-email=magento@example.com --admin-user=admin --admin-password=example123
Editing your .htaccess files
Your .htaccess files have several lines mentioning IfVersion. This requires 'mod_version' to be installed on the server. DreamHost servers running Bionic (Ubuntu 18.04) or Stretch (Debian 9) have this module installed, and do not require any further edits. If your web server has not yet been upgraded to either version, you must manually remove those lines from the .htaccess files. They are located in the following two locations:
- example.com/.htaccess
- example.com/pub/.htaccess
You can download the edited .htaccess file below for the website's home directory .htaccess file. NOTE: This is the Magento .htaccess file for version 2.3.5.
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.0, make sure you're using PHP 7.4. 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:
- Log into your database using phpMyAdmin.
- In the left pane, click your database name to select it.
- In the top menu, click the SQL tab.
- Enter the following command:
INSERT INTO `core_config_data`(`path`, `value`) VALUES ('admin/security/session_lifetime',864000)
- Click the Go button to run it.
- Log into your server via SSH. Make sure you're in your website's directory.
- Run the following commands:
[server]$ rm -rf var/cache/* [server]$ rm -rf var/page_cache/* [server]$ php bin/magento cache:flush
- Refresh your login page. You should now be able to log in.
Errors installing Extensions
You may see the following error when installing an extension.
The following sections explain how to resolve these errors.
Check Cron Scripts
Magento requires 3 different cron jobs to exist. View the following article for instructions on how to create a cron job:
You will need to create three separate cron jobs. In the following examples, change 'username' to your shell username, and 'example.com' to your Magento website.
In the following examples, username would be your Shell user and example.com your website.
Cron Job #1
/usr/local/php74/bin/php /home/username/example.com/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/username/example.com/var/log/magento.cron.log
Cron Job #2
/usr/local/php74/bin/php /home/username/example.com/update/cron.php >> /home/username/example.com/var/log/update.cron.log
Cron Job #3
/usr/local/php74/bin/php /home/username/example.com/bin/magento setup:cron:run >> /home/username/example.com/var/log/setup.cron.log
This will correctly configure the cron jobs Magento needs. However, you should now manually run them so Magento knows they exist. Run the following three commands to forcefully update the cron jobs in Magento:
[server]$ /usr/local/php74/bin/php /home/username/example.com/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/username/example.com/var/log/magento.cron.log
[server]$ /usr/local/php74/bin/php /home/username/example.com/update/cron.php >> /home/username/example.com/var/log/update.cron.log
[server]$ /usr/local/php74/bin/php /home/username/example.com/bin/magento setup:cron:run >> /home/username/example.com/var/log/setup.cron.log
Click the Try Again button in Magento. This time, the cron error will no longer show.
Check Component Dependency
Make sure you have set the memory_limit in your phprc file to 2000M. Additionally, update the following .user.ini file with the same value:
example.com/.user.ini
Once both files have memory_limit = 2000M set, run the three cron jobs above to update this information.
PHP Settings Check
Setting the PHP memory_limit to 2000 should fix this error.
PHP Extensions Check
Running the cron jobs above fixes this error.
Backup failed
During Step#2, you may see the backup failed.
If so, run the following command in your website directory.
[server]$ /usr/local/php74/bin/php bin/magento config:set system/backup/functionality_enabled 1
Click the Try Again button and your backup will be created.
Upgrading
Magento Open Source does not currently offer a method to update its software within the Admin panel. Updating requires the use of Composer and must be done via SSH. Below is the official Magento instructions for the process.