1. Home
  2. Magento 2 Guides
  3. Deploying static files

Deploying static files

For performance, Magento 2 now generates static files from your theme and other site components.  This feature is well documented at the Magento 2 dev docs, but there are some tricks to deploying and generating these files on MageMojo server.

Before deploying static files, you should remove any files in pub/static (but not the .htaccess file there!)

You should also clear the following, which will affect compilation, so you may want to do a full production mode deploy, instead.

  1. Delete all folders under pub/static
  2. Delete var/cache
  3. Delete var/composer_home
  4. Delete var/generation
  5. Delete var/page_cache
  6. Delete var/view_preprocessed
  7. Delete var/di (if it is present)

Then static files can be deployed using the following command (run from the bin directory in your Magento install).

This requires that your default PHP binary is PHP 5.6 or higher.  On MageMojo servers, the default is 5.4 in your path, though all the versions are available in /usr/bin.  This is a small bug in Magento 2 in that it won’t detect that your site is running under a PHP 7 pool.  To get around this, always run Magento 2 commands with the specific PHP version you need, deploy static files using this command –

Updated on October 3, 2017

Was this article helpful?

Related Articles