Magento 2 on Linux with Plesk

Manually adding Magento 2 to 1and1 Linux box with Plesk

Added a Magento 2.0 template from Templatemonster of all places and ran into substantial problems even after making sure we were in full compliance with Magento 2’s prerequisites. If your planning on this venture there are a few things you need to know.

Basics for Magento 2

  • MySql 5.6+ or greater
  • PHP 5.6.+ but NOT some of the 7+ packages so be cautious

Link for Magento official prerequisites: Here

These are for the basics for specifics please go to Magentos requirement page. If it caught you by suprise that some later packages as of this date are not compatable you’re certainly not alone. As we delve into this it becomes increasingly more resemblant of a beta and not a full fledged final software package.

So lets take the template from templatemonster which is free btw.

F2 – Free Magento 2.0 Theme Link: Here

You have to register, but it is indeed a free fully responsive Magento 2.0 theme also includes pictures and products with categories to boot.

  • Download template
  • Unzip
  • Take fullpackage.zip and upload to root through an FTP clien
  • Use ssh to Login to linux and goto root as well

Code:
unzip fullpackage.zip

  • Go to your website in any browser and you should see a magento setup page welcoming you. If not you may have to check permissions and prerequisites.
  • Upload the added sources folder from the magento template. This will be on he unzipped template folder on your PC.

ie: template_57559_mWq2X3gXn09q8E0zG7wv > sources_M67V82A7B6 > sources > sample_data

  • Upload the whole Pub folder to root and yes overwrite what’s there, should not replace anything just adding to images to template for sample data.
  • Same ‘sample_data’ folder there is a dump.sql file. We need to add this to the database BEFORE installing Magento.
  • Back to browser and install Magento

At this point you can goto your admin or homepage assumming the install was a sucess and you’ll quickly realize that there’s something wrong as the stylesheets and images are just not there. This is of course due to permissions and yes an out of the box solution of the new and improved Magento is well showing immidiate flaws. Moving on to fix this.

  • Login via ssh and goto root folder where magento is
  • Change file permissions

chown -R (NAME OF OWNER) /(YOUR FULL PATH TO ROOT)/
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml

Still Fubar? Try this again.
find . -type d -exec chmod 755 {} \;

To explain essentially we need directories and files

  1. Under ownership of user thus the chown
  2. All files with permissions of 644
  3. All directories with permissions of 755
  4. In the Var folder all directories permissions of 777
  5. In the Pub/Media folder all directories permissions of 777
  6. In the Pub/Static folder all directories permissions of 777
  7. If for whatever reason more permissions (which makes no sense) doesn’t work try making it 755. Yeah I know, but lets just move on.

Ok lets login to the admin. That menu not working? Some of the javascript not allowing you to manuver? Yeah … not file permissions just Magento. Sure there are fixes but lets just go ahead and upgrade regardless as these issues which btw are far from minor and should not even be in a beta package much less a full fledged release. (Yes this article shouldn’t be necessary nor exist but it is what it is.)

Still in ssh? great, Let’s do this (btw, the first line is for version 2.1.7 obviously can be any version, as of writing this 2.1.7 was the latest)

PLEASE NOTE: For whatever reason had do update to 2.1.6 first then to 2.1.7 , not sure as to why and wasn’t going to delve too far into a Magento upgrade glitch.

  • composer require magento/product-community-edition 2.1.7 --no-update
  • composer update --ignore-platform-reqs
  • (PATH TO PHP)/bin/php (PATH TO MAGENTO)/bin/magento setup:upgrade
  • (PATH TO PHP)/bin/php -d set_time_limit=3600 -d memory_limit=1024M /(PATH TO MAGENTO FOLDER)/bin/magento setup:di:compile

Flush the cash
(PATH TO PHP)/bin/php (PATH TO MAGENTO)/bin/magento cache:flush

Reindex. just for good measure
(PATH TO PHP)/bin/php /var/www/vhosts/(PATH TO MAGENTO FOLDER)/bin/magento indexer:reindex

Now if you log into the admin panel of Magento you should immediately see the magento version in the bottom right. As of 2.1.6 it looks like all of the basics are indeed working. Here’s a working example of the magento 2 now 2.1.7 with templatemonster F2 template. Here

Couple problems you May run into at least we did;
Problem:
"Warning: is_dir(): open_basedir restriction in effect. File(/etc/pki/tls/certs) is not within the allowed path(s):
Solution:
(PATH TO MAGENTO FOLDER)/composer.json
This:

 "config": { "use-include-path": true }, 

To this:

 "config": { "use-include-path": true, "disable-tls": true }, 

Problem:
Compilation was started.
Repositories code generation... 1/7 [====>-----------------------] 14% 1 sec 46.0 MiBPHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 94208 bytes) in (PATH TO MAGENTO)/vendor/zendframework/zend-code/src/Scanner/FileScanner.php on line 36

Solution:
When compiling as was noted above add right after calling PHP;
-d set_time_limit=3600 -d memory_limit=1024M

Problem:

 Uncaught Error: Call to undefined method Magento\Store\Model\ResourceModel\Store\Interceptor::___init() in (PATH TO MAGENTO)/var/generation/Magento/Store/Model/ResourceModel/Store/Interceptor.php:13

Solution:
Shoot for a lesser version of Magento. In our case had to do 2.1.6 then 2.1.7