4

We are working on a magento 2 project. Since Windows lack cron job, magento 2 refused work full fledged. We decided to install ubuntu.

After striving hard I was able to make PHP7, apach2, mySQL and phpmyadmin work. Now the next hurdle is Magento. It says

The localhost page isn’t working
localhost is currently unable to handle this request.
500

After hours of struggle I still have no idea on how to make it work.

Edit: I created a folder in var/www/html/Magento2 and copied all magento 2.02 files which has support for PHP7. Then I visit the Magento2 url. Bang I get the above error.

I need to confirm again PHP7 is working fine. Other scripts are working. I can even check for phpinfo. All the modules listed in the comment are installed.

PHP error log

[Sat Mar 12 10:09:29.489176 2016] [:error] [pid 1380] [client 127.0.0.1:44524] PHP Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Can't create directory /var/www/html/Magento2/var/generation/Magento/Framework/App/ResourceConnection/. in /var/www/html/Magento2/vendor/magento/framework/Code/Generator.php:103\nStack trace:\n#0 /var/www/html/Magento2/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...')\n#1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...')\n#2 [internal function]: spl_autoload_call('Magento\\Framewo...')\n#3 /var/www/html/Magento2/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\\Framewo...')\n#4 /var/www/html/Magento2/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Framewo...')\n#5 /var/www/html/Magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runt in /var/www/html/Magento2/vendor/magento/framework/Code/Generator.php on line 103

6
  • I rechecked for the magento2 requirements and installed the following extensions, still not working, - curl, gd, ImageMagick 6.3.7 (or later), intl, mbstring, mcrypt, mhash, openssl, PDO/MySQL, soap, xml, xsl, zip Commented Mar 11, 2016 at 12:42
  • check php error log
    – MagenX
    Commented Mar 11, 2016 at 14:07
  • Can you elaborate on when you get this error? When you first load magento after or before installation? Any errors in apache logs? also as @MagenX mentioned any errors in php error log? Also, how did you deploy? via composer-create project, downloaded zip from magento.com or via git clone?
    – Maddy
    Commented Mar 11, 2016 at 14:26
  • Looks like directory permission exception. Can you check the httpd's error log to get the more details ? Commented Mar 11, 2016 at 18:34
  • I get this error when I visit the URL for installation. Commented Mar 12, 2016 at 4:40

4 Answers 4

2
  1. Download magento2 from Magento Commerce website

  2. Create a folder magento under /var/www/html

  3. Extract all the files of magento2 under /var/www/html/magento

  4. Change the file permissions

     sudo chmod -R 777 /var/www/html/magento
    
  5. Create a database called magento

  6. Visit website url to install magento2

  7. After completing installation change the directory permission again

    sudo chmod -R 777 /var/www/html/magento
    
  8. Set environmental variables in ubuntu

    export PATH=$PATH:/var/www/html/magento/bin
    
  9. Setting up cron

    crontab -u <ubuntu_user_name> -e
    

Example:

crontab -u harish -e
  1. Select nano editor.

  2. Add the following lines at the end of the file

    */1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/bin/magento cron:run > 
    */1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/update/cron.php >
    */1 * * * * <path-to-binary> -c <ini-file-path> <your Magento install dir>/bin/magento setup:cron:run >
    

Where:

<path-to-binary> is the absolute file system path to your PHP binary

<ini-file-path> is the path to a php.ini file to use for the cron job

Example:

*/1 * * * * /usr/bin/php7.0 -c /etc/php/7.0 /var/www/html/magento/bin/magento cron:run > /var/www/html/magento/var/log/magento.cron.log&
*/1 * * * * /usr/bin/php7.0 -c /etc/php/7.0 /var/www/html/magento/update/cron.php > /var/www/html/magento/var/log/update.cron.log&
*/1 * * * * /usr/bin/php7.0 -c /etc/php/7.0 /var/www/html/magento/bin/magento setup:cron:run > /var/www/html/magento/var/log/setup.cron.log&
  1. Run cron from the command

    magento cron: run
    

I have explained the step by step installation of magento2 on ubuntu 14.04 with php7 in this post. It could help someone at least. Installing Magento2 on ubuntu with php7

0

Please go through below links for directory and file:

http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache-user.html

Hope this will help you for proper file/directory permissions.

3
  • The quide suggests 770 permission. But this is not working. Commented Mar 12, 2016 at 5:35
  • 755 permission works fine. Commented Mar 12, 2016 at 5:36
  • Its because of files/directory ownership , kindly update it with appropriate user/groups. It should be after do so. Commented Mar 12, 2016 at 5:37
0

we have installed magento2 on centos with php7 mariadb apache2 and nginx as proxy server with varnish redis and memcached also installed google page speed module. it is working fine except for suhosin which is required by our web panel i.e.. sentora. your problem seems to be broken installation. if you are using ubuntu is it clear that you first done a minimal install. and then installed everything. as if the default php and apache versions are still there it won't work as expected. post your detailed install process we might help.

0

Gone through your installation script. You have configured sites available in Apache. But I don't see where it configures sites enabled in Apache. Make sure that the site enabled configuration of Apache includes your Magento installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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