0

I'm having problems with Magento 2.2.6
I deploy and when I go to the site it does not load
Here's how I deploy:

php bin/magento deploy:mode:show
Current application mode: production. (Note: Environment variables may override this value.)

rm -rf /var/www/html/magento2/var/view_preprocessed/*
rm -rf /var/www/html/magento2/var/page_cache/*
rm -rf /var/www/html/magento2/pub/static/*

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

php bin/magento setup:static-content:deploy -f pt_BR en_US

cd /var/www/html/magento2
chown www-data:www-data -R *
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
chmod 777 ./generated

systemctl restart apache2
systemctl restart varnish
systemctl restart redis-server
systemctl restart mysql

Follows magento settings:
catalog/frontend/flat_catalog_category - 1
catalog/frontend/flat_catalog_product - 1
dev/template/minify_html - 1
dev/js/merge_files - 1
dev/js/enable_js_bundling - 1
dev/js/minify_files - 1
dev/css/merge_css_files - 1
dev/css/minify_files - 1
dev/grid/async_indexing - 1
dev/static/sign - 0

Access the site and error 500 in attachment (error.png)

I modify the /var/www/html/magento2/.htaccess file and add SetEnv MAGE_MODE developer
The site returns to work correctly without any errors (site.png).
When I comment this line back does not work

I can not find where the error is.
I want to leave the site in production mode but ERROR 500 occurs

I would like your help if possible.

error.png error.png

site.png site.png

2

At a quick glance, you're probably running into one or more missing classes. In production mode, Magento doesn't generate any files; instead, it expects you to manually run bin/magento setup:di:compile and bin/magento setup:static-content:deploy on your own.

I see you run bin/magento setup:static-content:deploy; however, you never compile the dependency injection code. This generates all the interceptors, proxies, and other "missing" classes that are normally generated on-the-fly when in developer mode.

I would look in your Apache error logs to see the caught 500 error. You could also check the PHP error logs, as well as the exception and system logs in Magento.

When building a deployment for my site, I do the following steps:

  1. Update branch to be deployed: git fetch && git pull
  2. Set the deployment mode to production (just to be sure): bin/magento deploy:mode:set production
  3. Install composer dependencies: composer install --no-dev --no-suggest --optimize-autoloader
  4. Run upgrade to bring database up-to-date: bin/magento setup:upgrade
  5. Run Magento compilation for dependency injection files: bin/magento setup:di:compile
  6. Generate static content: bin/magento setup:static-content:deploy <lang_Code(s)>

At this point, you should have a bunch of files in the generated, var/view_preprocessed and pub/static folders. The files that you are most likely missing are those in the generated folder.

0

composer install --no-dev --no-suggest --optimize-autoloader
Generating optimized autoload files
Warning: Ambiguous class resolution, "Plazathemes\Newproductslider\Block\Newproductslider" was found in both "/var/www/html/magento2/app/code/Plazathemes/Newproductslider/Block/Newproductslider - Copy.php" and "/var/www/html/magento2/app/code/Plazathemes/Newproductslider/Block/Newproductslider.php", the first will be used.
Warning: Ambiguous class resolution, "Plazathemes\Template\Controller\Adminhtml\Template\Save" was found in both "/var/www/html/magento2/app/code/Plazathemes/Template/Model/Save.php" and "/var/www/html/magento2/app/code/Plazathemes/Template/Controller/Adminhtml/Template/Save.php", the first will be used.

magento setup:upgrade
magento setup:di:compile
chmod -R 0777 var/ pub/ generated/

I performed all the steps that I related in the first post

php bin/magento deploy:mode:set developer
Enabled developer mode.

php bin/magento deploy:mode:set production
Enabling maintenance mode
Config "dev/debug/debug_logging = 0" has been saved.
Starting compilation
Compilation was started.
%message% 0/7 [>---------------------------] 0% < 1 sec 38.0 MiB%message% 0/7 [>---------------------------] 0% < 1 sec 38.0 MiBProxies code generation... 0/7 [>---------------------------] 0% < 1 sec 38.0 MiB
Proxies code generation... 1/7 [====>-----------------------] 14% < 1 sec 42.0 MiB
Repositories code generation... 1/7 [====>-----------------------] 14% < 1 sec 42.0 MiB
Repositories code generation... 2/7 [========>-------------------] 28% 17 secs 112.0 MiB
Service data attributes generation... 2/7 [========>-------------------] 28% 17 secs 112.0 MiB
Service data attributes generation... 3/7 [============>---------------] 42% 17 secs 114.0 MiB
Application code generator... 3/7 [============>---------------] 42% 17 secs 114.0 MiB
Application code generator... 4/7 [================>-----------] 57% 33 secs 126.0 MiB
Interceptors generation... 4/7 [================>-----------] 57% 33 secs 126.0 MiB
Interceptors generation... 5/7 [====================>-------] 71% 53 secs 148.0 MiB
Area configuration aggregation... 5/7 [====================>-------] 71% 53 secs 148.0 MiB
Area configuration aggregation... 6/7 [========================>---] 85% 1 min 226.0 MiB
Interception cache generation... 6/7 [========================>---] 85% 1 min 226.0 MiB
Interception cache generation... 7/7 [============================] 100% 1 min 226.0 MiB
Generated code and dependency injection configuration successfully.
Compilation complete
Starting deployment of static content

Deploy using quick strategy
frontend/Magento/blank/pt_BR 2196/2196 ============================ 100% % 1 min adminhtml/Magento/backend/pt_BR 2151/2151 ============================ 100% % 1 min frontend/Magento/blank/en_US 2196/2196 ============================ 100% % 1 min frontend/Magento/luma/pt_BR 2212/2212 ============================ 100% % 1 min adminhtml/Magento/backend/en_US 2151/2151 ============================ 100% % 1 min frontend/Cigar/cigar3/pt_BR 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar2/pt_BR 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar4/pt_BR 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar1/pt_BR 2242/2242 ============================ 100% % 1 min frontend/Magento/luma/en_US 2212/2212 ============================ 100% % 1 min frontend/Cigar/cigar3/en_US 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar2/en_US 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar4/en_US 2242/2242 ============================ 100% % 1 min frontend/Cigar/cigar1/en_US 2242/2242 ============================ 100% % 1 min

Execution time: 1187.2419559956 Deployment of static content complete Disabling maintenance mode
Enabled production mode.

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

fix permissions (reported in the first post)

exception.log showed this error but I believe it occurred during the execution of the commands and then did not appear any more

/var/www/html/magento2/var/log/exception.log [2018-11-25 05:30:17] main.CRITICAL: Can't create directory /var/www/html/magento2/generated/code/Magento/Framework/Notification/NotifierInterface/. Class Magento\Framework\Notification\NotifierInterface\Proxy generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. {"exception":"[object] (RuntimeException(code: 0): Can't create directory /var/www/html/magento2/generated/code/Magento/Framework/Notification/NotifierInterface/. Class Magento\Framework\Notification\NotifierInterface\Proxy generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only. If --- after running the 'bin/magento setup:di:compile' CLI command when the 'generated' directory permission is set to write --- the requested class did not generate properly, then you must add the generated class object to the signature of the related construct method, only. at /var/www/html/magento2/vendor/magento/framework/Code/Generator.php:135)"} []

  • The error is claiming that the web server doesn't have write access to the "generated" folder. Is it possible the user your webserver is running as is not "www-data" and is something like "apache" or "apache2"? – Brett Nov 26 '18 at 7:41
0

You have the permissions set.

  • 644 permission for files

    find . -type f -exec chmod 644 {} \;

  • 755 permission for the directory

    find . -type d -exec chmod 755 {} \;

  • 777 permission for var folder

    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

Note: Use sudo if not using with root user.

0

I gave up this installation I deleted VPS and created a new one from the beginning I'm going to use Nginx and PHP-FPM instead of Apache and PHP7.0 Should I use php7.0 from the default repository or add a new repository and use 7.1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.