0

Getting error when i try to run following command,

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

Error: enter image description here

Errors: SSL connection Timeout error, Resolving timed out after 10000 milliseconds, Connection time-out Now trying to download from source.

**In CurlDownloader.php line 390:

curl error 28 while downloading https://repo.magento.com/archives/magento/composer-dependency-version-audit-plugin/magento-composer-dependenc
y-version-audit-plugin-0.1.6.0.zip: Connection time-out**

How to solve this error?

Error: enter image description here

2 Answers 2

1

First check your php version for installing the Magento 2.4.7.

Magento Open Source 2.4.7 introduces support for PHP 8.3. so make sure you have php version 8.3 present in your system.

To install the Magento via composer you can follow the below steps

  1. Below extension should be enabled in your local server if you are installing on windows system.

Go to your php.ini file

 extension=php_intl extension=soap extension=sockets` extension=php_xsl extension=sodium extension=gd 
  1. Create Database for Magento Project in phpMyAdmin.

  2. Install the Magento via composer by using the following command

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:version ./ 
  1. Then Download the elastic by following link https://www.elastic.co/downloads/past-releases/elasticsearch-7-1-0

  2. Run the Elastic search to go into the elasticsearch-7.17.0\bin\elasticsearch batch file

  3. Once composer directory setup on your system then Copy .htaccess file in pub folder and paste in root directory

  4. Copy index.php file in pub folder and paste in root directory and change the bootstrap file path there

  5. Now go to this file vendor\magento\framework\Image\Adapter\Gd2.php file (if window system)

Find below function replace with this code there

private function validateURLScheme(string $filename) : bool { $allowed_schemes = ['ftp', 'ftps', 'http', 'https']; $url = parse_url($filename); if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) { return false; } return true; } 
  1. Then go to this file vendor\magento\framework\View\Element\Template\File\Validator.php file: (if window system)

Find below function replace with this code there

protected function isPathInDirectories($path, $directories) { if (!is_array($directories)) { $directories = (array)$directories; } $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path)); //This Line Especially foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) { return true; } } return false; } 
  1. Then you need to run install command for the db and replace the "magento" with you directory name and run this command on the magento2 root
php bin/magento setup:install --base-url="http://localhost/magento/" --db-host="localhost" --db-name="magento" --db-user="root" --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --admin-user="admin" --admin-password="admin123" 
  1. Once done these things then you need to add the url into the core_config_data table.

By following command you can add the url into the db run the following query in sql db incase you don't change name in install command.

replace the "magento" with your directory name

INSERT INTO core_config_data (config_id, scope, scope_id, path, value, updated_at) VALUES (NULL, 'default', '0', 'web/secure/base_static_url', 'http://localhost/magento/pub/static/', current_timestamp()), (NULL, 'default', '0', 'web/unsecure/base_static_url', 'http://localhost/magento/pub/static/', current_timestamp()), (NULL, 'default', '0', 'web/secure/base_media_url', 'http://localhost/magento/pub/media/', current_timestamp()), (NULL, 'default', '0', 'web/unsecure/base_media_url', 'http://localhost/magento/pub/media/', current_timestamp()); 
  1. Also for running the magento default it's comming with 2 factor authuntication module enable in magento side

if you want you can disable first module by following command

php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth php bin/magento module:disable Magento_TwoFactorAuth 
  1. Then run following command
php bin/magento s:up php bin/magento s:di:compile php bin/magento s:static-content:deploy -f php bin/magento c:f rm -rf generated/metadata 
11
  • I am getting following error, url not return the homepage, i.sstatic.net/M6gqzmOp.png Commented Jan 2 at 13:59
  • 1
    Please check this url if working : localhost/magento/pub If working then Copy the .htaccess,index.php file from the pub folder and add it on the magento root directory. also have you change the base url in core_config_data table with your url Commented Jan 3 at 4:49
  • In my base url in core_config_data table localhost/magento same right? Commented Jan 3 at 10:15
  • yes, if you can add screenshot of both url : localhost/magento/pub and localhost/magento that would be helpful Commented Jan 3 at 11:02
  • 1
    You can edit the index.php replace this "require DIR . '/../app/bootstrap.php';" with "require DIR . '/app/bootstrap.php';" Commented Jan 3 at 12:51
1

Solution 1: Create a virtual host and point it to pub directory.

We were using the base_url as http://127.0.0.1/magento247. So instead of this now we need to use http://127.0.0.1/magento247/pub as the base_url. Secure and Unsecured URL needs to be setup based on this.

Solution2: Adding /pub follow the below steps

  1. Copy .httaccess file from pub folder and override it to root .htaccess file

  2. Upload pub/index.php file to root magento directory

  3. Add below code in app/etc/env.php file

'system' => [ 'default' => [ 'web' => [ 'unsecure' => [ 'base_media_url' => '{{secure_base_url}}pub/media/', 'base_static_url' => '{{secure_base_url}}pub/static/' ], 'secure' => [ 'base_media_url' => '{{secure_base_url}}pub/media/', 'base_static_url' => '{{secure_base_url}}pub/static/' ] ] ] ], 
3
  • env.php -> smalldev.tools/share-bin/VmCaNDYY Commented Jan 3 at 11:37
  • localhost/magento return -> I am getting following error: Warning: require(C:\xampp\htdocs\magento/../app/bootstrap.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\magento\index.php on line 12 Fatal error: Uncaught Error: Failed opening required 'C:\xampp\htdocs\magento/../app/bootstrap.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\magento\index.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\magento\index.php on line 12 Commented Jan 3 at 11:42
  • 1
    Change require DIR . '/../app/bootstrap.php'; to require DIR . '/app/bootstrap.php'; in index.php file , please check more details here polacin.com/blog/post/… Commented Jan 3 at 13:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.