cancel
Showing results for 
Search instead for 
Did you mean: 

Installation of Magento 2 On Ubuntu 20.4.

Installation of Magento 2 On Ubuntu 20.4.

Hi I install magento 2 on my localhost following the instruction from the below link.

https://www.thecoachsmb.com/how-to-install-magento-2-on-ubuntu/ 

My base URL is http://test.magento.com. They base URL is not woking and when I go my http://localhost.com/, Insted of apache default page it's showing me this.

<?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);

Can someone help me on how to debug it or get this issue resolved? 

6 REPLIES 6

Re: Installation of Magento 2 On Ubuntu 20.4.

Hello @prashantguce2c ,

 

The issue is with your virtual host modifications, you should copy the default vhost and do changes in the new one, restore them with old configurations back, make sure your "http://localhost/" works fine again, then recreate virtual hosts like below :

https://magento.stackexchange.com/a/245741

 

before creating virtual host, you can run your magento on localhost with subdomain as well : http://localhost/<magento install directory> and change your web base url same.

 

Hope it helps !

 

 

 

 

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Installation of Magento 2 On Ubuntu 20.4.

Hi I remove the previous install magento and reinstall it without base URL option in the directory name magento2

localhost  is working fine. But when in 

/etc/apache2/sites-available/000-default.conf

I edit DocumentRoot /var/www/html

http://localhost/magento2/.

It's giving me 404. and when I edit

DocumentRoot /var/www/html/magento2. It's giving me the same error.

<?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);

Can you please tell me how to fix this?

Re: Installation of Magento 2 On Ubuntu 20.4.

@prashantguce2c , it looks like your php is not working or having some conflicts. It is only reading the PHP file rather compiling it.

can you test running this in terminal and show output here :

php -v

Let me know the results here.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Installation of Magento 2 On Ubuntu 20.4.

php -v
PHP 7.4.28 (cli) (built: Feb 17 2022 16:06:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

Also inside magento install directory. Php cli command are working ok like.

PHP bin/magento cache:flush

Re: Installation of Magento 2 On Ubuntu 20.4.

if PHP is installed but Apache is not able to use it. can you try to restart your apache server

sudo service apache2 restart

if still not working then share your vhost file here.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Installation of Magento 2 On Ubuntu 20.4.

Restarting apache does not work. This is my vhost file.

 

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        <Directory "/var/www/html">
        AllowOverride all
        </Directory>

</VirtualHost>

 

Right now. As mentioned above I have install magento again but without base URL. Now localhost/<install_dir> in giving 404