'How to resolve errors while installing magento 2 for the first time with php, nginx and mysql

I am trying to setup Magento 2 on my windows 10 machine via Ubuntu WSL. As of yet I have successfully installed PHP 7.4, MySQL 8.0 and NGINX. While installing Magento 2, I get the following error -

An exception was raised while creating "Application"; no instance returned#0 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback()
#1 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory()
#2 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate()
#3 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create()
#4 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Application.php(261): Zend\ServiceManager\ServiceManager->get()
#5 /var/www/html/magento2/lib/internal/Magento/Framework/Console/Cli.php(72): Zend\Mvc\Application::init()
#6 /var/www/html/magento2/bin/magento(24): Magento\Framework\Console\Cli->__construct()
#7 {main}

An exception was raised while creating "Request"; no instance returned#0 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback()
#1 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory()
#2 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate()
#3 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create()
#4 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Application.php(113): Zend\ServiceManager\ServiceManager->get()
#5 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Service/ApplicationFactory.php(29): Zend\Mvc\Application->__construct()
#6 [internal function]: Zend\Mvc\Service\ApplicationFactory->createService()
#7 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(939): call_user_func()
#8 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback()
#9 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory()
#10 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate()
#11 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create()
#12 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Application.php(261): Zend\ServiceManager\ServiceManager->get()
#13 /var/www/html/magento2/lib/internal/Magento/Framework/Console/Cli.php(72): Zend\Mvc\Application::init()
#14 /var/www/html/magento2/bin/magento(24): Magento\Framework\Console\Cli->__construct()
#15 {main}

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/html/magento2/vendor/zendframework/zend-stdlib/src/ArrayObject.php on line 426#0 /var/www/html/magento2/vendor/composer/ClassLoader.php(571): Magento\Framework\App\ErrorHandler->handler()
#1 /var/www/html/magento2/vendor/composer/ClassLoader.php(571): include()
#2 /var/www/html/magento2/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#4 /var/www/html/magento2/vendor/zendframework/zend-stdlib/src/Parameters.php(29): spl_autoload_call()
#5 /var/www/html/magento2/vendor/zendframework/zend-console/src/Request.php(96): Zend\Stdlib\Parameters->__construct()
#6 /var/www/html/magento2/vendor/zendframework/zend-console/src/Request.php(122): Zend\Console\Request->getParams()
#7 /var/www/html/magento2/vendor/zendframework/zend-console/src/Request.php(66): Zend\Console\Request->params()
#8 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Service/RequestFactory.php(29): Zend\Console\Request->__construct()
#9 [internal function]: Zend\Mvc\Service\RequestFactory->createService()
#10 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(939): call_user_func()
#11 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback()
#12 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory()
#13 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate()
#14 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create()
#15 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Application.php(113): Zend\ServiceManager\ServiceManager->get()
#16 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Service/ApplicationFactory.php(29): Zend\Mvc\Application->__construct()
#17 [internal function]: Zend\Mvc\Service\ApplicationFactory->createService()
#18 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(939): call_user_func()
#19 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(1097): Zend\ServiceManager\ServiceManager->createServiceViaCallback()
#20 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(638): Zend\ServiceManager\ServiceManager->createFromFactory()
#21 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate()
#22 /var/www/html/magento2/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create()
#23 /var/www/html/magento2/vendor/zendframework/zend-mvc/src/Application.php(261): Zend\ServiceManager\ServiceManager->get()
#24 /var/www/html/magento2/lib/internal/Magento/Framework/Console/Cli.php(72): Zend\Mvc\Application::init()
#25 /var/www/html/magento2/bin/magento(24): Magento\Framework\Console\Cli->__construct()
#26 {main}

I am following the guide provided in link - https://www.simicart.com/blog/magento-2-nginx/#Step_4_Configure_nginx . I am getting the error while executing the step 7 in guide.

I tried researching these errors but all are pointing towards an issue in upgrade while this is a first time I am installing magento. I proceeded to executing step 8 but still getting the same set of errors.



Solution 1:[1]

Could you please run this and paste the output?

php -m

I took a quick look at that guide and it doesn't seem that it tells you to install all the necessary PHP extensions for Magento 2.

P.S. There are two different steps #7 in the guide. If you are stuck in the second one, run the following command and post the output here:

sudo systemctl status nginx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asmir Pekmic