0

Hi I have been trying to install Magento 2 on my Ubuntu localhost. I followed the below-mentioned command.

 sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition mag2

Then

cd /var/www/html/mag2

sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + sudo chown -R user_name:www-data . sudo chmod u+x bin/magento

Then running.

     sudo php bin/magento setup:install \
--base-url=http://localhost/magento2 \
--db-host=localhost \
--db-name=magento2 \
--db-user=magento2 \
--db-password=<pasword> \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch7 \
--elasticsearch-host=localhost \
--elasticsearch-port=9200

But when I go the `http://localhost/magento2/. I'm getting below mention error on my browser.

<?php
/**
 * Public alias for the application entry point
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

use Magento\Framework\App\Bootstrap;

try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
    <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
        <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
        Autoload error</h3>
    </div>
    <p>{$e->getMessage()}</p>
</div>
HTML;
    exit(1);
}

$bootstrap = Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$bootstrap->run($app);

I try installing it by vhost which didn't work. I check all the dependences of Magento 2 like Apache2, Php and its modules, elasticsearch all the packages are working fine.

Can someone help me with resolving and debugging this issue? One more thing when I ran the composer installation it's not asking for a Username or password as mentioned in the installation guide.

2 Answers 2

0

First of the set the 777 permission of the project folder then follow as below.

Set the folder and file permission as below first.

find . -type f -exec chmod 644 {} \;                        // 644 permission for files
find . -type d -exec chmod 755 {} \;                        // 755 permission for directory

then run below command.

sudo rm -rf pub/static/frontend sudo rm -rf pub/static/adminhtml sudo rm -rf var/cache sudo rm -rf var/composer_home sudo rm -rf var/generation sudo rm -rf var/page_cache sudo rm -rf var/view_preprocessed sudo rm -rf var/log sudo rm -rf generated/code/ sudo rm -rf generated/metadata/

after run this command follow below command.

php bin/magento maintenance:enable
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:di:compile
php bin/magento maintenance:disable
php bin/magento cache:flush
php bin/magento indexer:reindex
sudo chmod -R 777 var/ generated/ pub/media/ pub/static/

Note: Make sure Elasticsearch install in your localhost.

Hope it's help to you.

2
  • it's still not working all the commands run fine without any error but, getting the same error on the browser as mentioned above. Any other way to figure this out. Mar 9 at 6:51
  • Share your core_config_data table data for base URL and Magento version and PHP version etc then i will help you Mar 9 at 8:39
0

Please run below commands:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:di:compile
php bin/magento indexer:reindex
php bin/magento cache:flush
sudo chmod -R 777 var/ generated/ pub/media/ pub/static/

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.