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
- 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
Create Database for Magento Project in phpMyAdmin.
Install the Magento via composer by using the following command
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:version ./
Then Download the elastic by following link https://www.elastic.co/downloads/past-releases/elasticsearch-7-1-0
Run the Elastic search to go into the elasticsearch-7.17.0\bin\elasticsearch batch file
Once composer directory setup on your system then Copy .htaccess file in pub folder and paste in root directory
Copy index.php file in pub folder and paste in root directory and change the bootstrap file path there
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; }
- 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; }
- 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"
- 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());
- 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
- 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