http://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html
1. Go to your server root or directory where you want to install Magento 2 and open that folder in the terminal.
2. Copy following command and run it inside that folder in the terminal.
git clone git@github.com:magento/magento2.git
3. Wait until the clone download complete.
4. Now run the following command:
composer install
5. Now run following command to give permission to cache and pub directory.
chmod-R 777 var/ pub/ generated/
chmod -R 777 app/etc/
Now fill all the information and complete the installation
OR
Please change your db-user,db-password ,db-name and other parameter value according to your database details and magento configration.
php -f bin/magento setup:install –base-url=http://m2.loc/2.07/github/ --backend-frontname=admin
--db-host=localhost --db-name=yourdbname --db-user=root --db-password=yourdbpassword --admin-firstname=Zarvis
--admin-lastname=User --admin-email=root@w3ctrl.com --admin-user=admin --admin-password=magento1223
--language=en_US --currency=USD --timezone=America/Chicago –use-rewrites=1
git@github.com:magento/magento2-sample-data.git
7. How to set permission to Magento 2 files and folder
chown -R :your web server group name
find . -type d -exec chmod g+ws {} \;
chown -R :your web server group name
find . -type d -exec chmod g+ws {} \;
8. Clear cache using follwoing command
Go to Magento 2 var/ folder
rm -rf cache/* page_cache/* generation/*
9. Run the following commands to install sample data:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:di:compile
Please view the following video for magento 2 installtion
Thanks