Kindly enough, DreamHost offers some documentation about setting up Magento on their servers, but unfortunately it doesn’t really cover a lot of the issues you may run into. Here’s how we did it.

Pre-Setup:

  • Make sure you are using a VPS with adequate resources. Would suggest 1 GB RAM to start.
  • PHP 7.1 or higher on front end and back end (CLI). If you change your PHP version, make sure you kill all current processes to have it take affect:
killall -9 php56.cgi -u shelluser
  • Set your PHP memory limit higher than 90 MB. We have had success with 512, but DreamHost recommends 756 MB.
  • Enable the intl extension in your phprc file:
extension=intl.so

Step 1. Load your Magento archive into your root directory (the place where it will live)

You can do this via SSH or FTP, but if you do it via FTP, load in the .tar, .zip, or .tar.bz2 and then connect via SSH to unpack it to make sure everything gets the right permissions.

Step 2. Unpack via SSH

For zip:

unzip filename.zip

For gz:

gunzip filename.gz

For tar:

tar xvf filename.tar

For tar.gz:

tar xvzf filename.tar.gz

For tar.bz2:

tar xvjf filename.bz2

Step 3. Edit .htaccess

Before you can even access your Magento install, you will need to edit your root htaccess AND (IMPORTANT) your htaccess in your public folder… /pub Since DreamHost is running Apache 2.2, you will need to edit out any instances of IfVersion referencing Apache 2.4.

Change ANY and ALL lines that look like this:

<Files composer.json>
  <IfVersion < 2.4>
    order allow,deny
    deny from all
  </IfVersion>
  <IfVersion >= 2.4>
    Require all denied
  </IfVersion>
</Files>

To this:

<Files composer.json>
  order allow,deny
  deny from all
</Files>

Again, you will have to do this in the root directory AND pub directory or else your CSS and JS files will not be accessible

Step 4. Run the installer

Access your Magento install by typing the URL of where it will be into your browser bar. Once installation is complete, you should be able to access your admin area.

Step 5. Deploy static content

Back in SSH, find your root directory and run:

php /bin/magento setup:static-content:deploy

You may run into some issues at this step.

“Permission denied”. If you’re running the command without php as a prefix, you’ll run into this issue. Run:

chmod +x bin/magento

Then rerun the deploy static content command.

If it tells you that it supports 7.0.4, 7.0.6, etc, you will want to check and make sure your CLI is running PHP 7.1 or newer. Run:

php -v

to see what version PHP you are running. If it isn’t, add an alias to your root .bash_profile to force the newer version:

alias php='/usr/local/php72/bin/php'

Or…

export PATH=/usr/local/php72/bin:$PATH



Log out and log back in for the changes to take affect. Run php -v to confirm your changes are working.

Try to deploy the content again. If at this point you run out of memory, you will want to make sure that the memory limit in your phprc is set high enough as mentioned in the pre-setup. You can confirm what the memory limit is by running:

php -i | grep memory

Step 6. Check everything works.

Troubleshooting

None of my CSS or JS is loading! I am getting a weird version in my URL for my files! Etc.

This is a setting that hides under Stores > Configuration > Advanced > Developer > Sign Static Files. You probably won’t be able to access this if CSS or JS isn’t working, so you can edit it in PHPMyAdmin instead.

Crack open PHPMyAdmin and take a look at your tables. Find the table core_config_data and run:

insert into core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0); 

In SSH, flush your cache…

bin/magento cache:clean
bin/magento cache:flush

Try it again and see if it works.

Still no luck?

Check your htaccess fileS. Yes, more than one. Check if any of the IfVersion information we edited at the beginning is present. You will need to edit it out to get things to work properly.

Hopefully this short guide will help you out with some of the problems you may have installing Magento on your DreamHost VPS. Thanks to Chris L for the assist!

Want to get updates like this delivered straight to your inbox?
Subscribe to our blog to receive website design tips, development tricks, the latest in SEO, and more. We don't share your email address with anyone and you can unsubscribe at any time.

Comments are closed.