Magento can be setup in 4 different ways, here i’m touching just the 4th – through composer.
- Composer create project, the final parameter is where it will be installed Magento. In my case “./”, it is in the current directory.
1 2 3 |
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition ./ |
During installation I got a series of problems, I’ll try to add them between steps so you know what it can happen, example:
Composer failing on Mac (OSX) with MAMP Pro with the following message
1 2 3 4 |
- Your requirements could not be resolved to an installable set of packages. - the requested PHP extension mcrypt is missing from your system |
More about this error in this post: Composer – PHP Error
so it has to be run this command :
1 2 3 |
php /usr/local/bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition project_name |
2. Follow the Web setup of your domain (my localhost domain is: mage.dev).
1 2 3 |
http://mage.dev/setup |
- If after setup you get this error:
1 2 3 |
"Unable to retrieve deployment version of static files from the file system...." |
That means the static files were not generated and you have to go in command line (cli) and run the following command
1 2 3 4 5 |
# it is very important to have the "en_GB" (or other language) # as this was the main reasons not to generate properlly php bin/magento setup:static-content:deploy en_GB |
Another encountered error was:
1 2 3 4 5 |
[error] 13168#2222: *43 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Cannot instantiate interface Magento\Framework\App\Config\Scope\ReaderPoolInterface in /var/www/magento/web/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:73" |
The solution was well described in this post on StackExchange which is :
1 2 3 4 5 6 7 8 9 10 11 |
If you use Nginx configuration from the official sample and running Magento in the default/developer mode this situation might happen with document root global value set as > root $MAGE_ROOT/pub; The issue can be fixed by setting Magento root from pub directory to the root index.php > root $MAGE_ROOT; |
- Problem: No images, css or js files loading (404 error) – after reaching this point and your website is still not accessible is seems there could have been an error on generating in correct order the static files:
1 2 3 4 5 6 7 8 |
#make sure the project has the correct GROUP permissions sudo chown -R :www-data ./ # make sure the permissions for this 2 folders are 0777 sudo chmod -R 0777 var/ sudo chmod -R 0777 pub/static |
After permissions checks we have to generate the static files (thanks to Angelo’s tips)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Clearing cache... sudo rm -rf var/cache/ \ && sudo rm -rf var/generation/ \ && sudo rm -rf var/di/ \ && sudo rm -rf var/page_cache/ \ && sudo rm -rf var/view_preprocessed/ # Compiling dependency injection... php bin/magento setup:di:compile # Deploying static content... php bin/magento setup:static-content:deploy php bin/magento setup:static-content:deploy en_GB |
3. Make sure you have the latest packages
1 2 3 4 |
composer update bin/magento setup:upgrade |
4. To add the Sample Data make sure this configuration is present into composer.json :
1 2 3 4 5 6 7 8 |
"repositories": [ { "type": "composer", "url": "https://repo.magento.com/" } ], |
4..1 Deploy sample data
1 2 3 |
bin/magento sampledata:deploy |
This step is a bit misleading as you get this message:
And my initial thought and action was to add my username from https://magentocommerce.com but it doesn’t work so after a bit of research I found out I need in fact to get the magentocommerce.com > Connect > Secure Keys my Public and Private Key which are looking like this:
or in the new interface at
https://marketplace.magento.com/customer/accessKeys/list/After that the installation of sample data went smoothly.
4.2. After deploy yo have to run:
1 2 3 |
php bin/magento setup:upgrade |
5. Developing in Magento (Set the Mode, enable URN for PhpStorm)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
### Developer Enviroment ### #Set developer mode bin/magento deploy:mode:show bin/magento deploy:mode:set developer #Generate URN cache (XSDs) for use in PhpStorm: bin/magento dev:urn-catalog:generate .idea/misc.xml #Enable Magento_Developer module bin/magento module:enable Magento_Developer #Optionally enable profiler in shell export MAGE_PROFILER=firebug ### For PRODUCTION you would go with this values Set production mode bin/magento deploy:mode:set production #Disable Magento_Developer module bin/magento module:disable Magento_Developer |