AI Tools | ChatGPT Alternative for banned countries

Installing magento2 from Source ( Github )


1- Clone Magento Source:

git clone git@github.com:magento/magento2.git

 

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 https://docs.swissuplabs.com/packages/
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=http://magento.darelm.cc/ --backend-frontname=admin --db-host=localhost --db-name=dev_magento --db-user=root --db-password=root --admin-firstname=Magento --admin-lastname=Admin --admin-email=saleh.awal@gmail.com --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

127.0.0.1     your-local-domain.cc

- 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
    </Directory>
</VirtualHost> 

save and restart apache

sudo systemctl restart apache2

 

6- Test your site

Navigate to your local domain on the browser : your-local-domain.com


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

1- Install Elastic Search

- download and install public signing key

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt 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:
network.host: 127.0.0.1
http.port: 9200
change resource consumtion setting in file:
sudo nano /etc/elasticsearch/jvm.options
set ram max and min as you like:
-Xms1g
-Xmx1g

- 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: 127.0.0.1 port:9200:
http://127.0.0.1:9200/


Enjoy 😀


Sources:
https://devdocs.magento.com/guides/v2.4/install-gde/composer.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html

Comments