Installing magento2 from Source ( Github )

1- Clone Magento Source:

git clone


2- Install dependencies:

composer install


3- install magento

- remove elastic search modules ( just in case it dose not blocks the install process )

bin/magento module:disable Magento_Elasticsearch Magento_Elasticsearch6 Magento_Elasticsearch7

- magento mysql search englins was deprecated since 2.4, in order to enable legacy mysql we need to install this plugin:

composer config repositories.swissup composer
composer require swissup/module-search-mysql-legacy --prefer-source --ignore-platform-reqs
bin/magento module:enable Swissup_SearchMysqlLegacy Swissup_Core
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento indexer:reindex catalogsearch_fulltext

then enable the mysql engins

bin/magento config:set catalog/search/engine 'lmysql'

- start installation

php -f bin/magento setup:install --base-url= --backend-frontname=admin --db-host=localhost --db-name=dev_magento --db-user=root --db-password=root --admin-firstname=Magento --admin-lastname=Admin --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=Africa/Cairo --use-rewrites=1


4- Configure File Permission: 

- add local user to apache user group

usermod -a -G www-data {username}

- change magento folder ownership to apache group

chmod {username}:www-data /magento/folder/location -Rf


5- Configure Appache Server

- add new domain to hosts

- add new site

cd /etc/apache2/sites-available/ 
sudo touch {your-site-name}.conf
sudo nano {your-site-name}.conf

add the below code after modifing it to meet your needs

<VirtualHost {your-site}:80>
    ServerName {your-site}
    ServerAdmin {your-email}
    ServerName {your-site-name}
    ServerAlias www.{your-site}
    DocumentRoot {magento/folder/location}
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        require all granted

save and restart apache

sudo systemctl restart apache2


6- Test your site

Navigate to your local domain on the browser :

Note: if you want to enable elasticsearch, follow these steps:

1- Install Elastic Search

- download and install public signing key

wget -qO - | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

- install elasticsearch
sudo apt-get update
sudo apt-get install elasticsearch

- configure elastic search
open this file:
sudo nano /etc/elasticsearch/elasticsearch.yml
and add the following at the end of the file:
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
uncomment host and port and set them as you like:
http.port: 9200
change resource consumtion setting in file:
sudo nano /etc/elasticsearch/jvm.options
set ram max and min as you like:

- start elasticsearch
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service

- you can test if it is working by sending a GET request to: port:9200:

Enjoy 😀